在网上找到一个用来检查文章中重复词的宏,但是在测试时提示子过程或函数未定义,不知道怎么修改,求个高手帮帮忙。
代码如下:
Sub FinReP()
Dim iRng As Range, jRng As Range
Dim i As Integer, j As Integer, o As Integer
Set iRng = ActiveDocument.Content
With iRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(findtext:="<[!^13]@^13<[!^13]@^13", MatchWildcards:=True)
Set jRng = iRng.Duplicate
i = 1
For j = 0 To Len(iRng) - 1
Set jRng = Range(iRng.Start + j, iRng.Start + j + 1)
If jRng Like "[一-﨩]" And jRng.Font.Color = wdColorAutomatic Then
Set fRng = Range(jRng.End, iRng.End)
o = 0
Do While fRng.Find.Execute(findtext:=jRng, MatchWildcards:=False)
i = i + 1
jRng.Font.ColorIndex = i - o
fRng.Font.ColorIndex = i - o
fRng.SetRange fRng.End, iRng.End
o = o + 1
Loop
End If
Next
iRng.SetRange iRng.End, ActiveDocument.Content.End
Loop
End With
End Sub
2ã对åè¿ç¨ï¼æå½æ°ï¼çå®ä¹ä¸ä¸è´ã
ä¾å¦ï¼åè¿ç¨test1åå¨æ个工ä½è¡¨ä¸ï¼è®¾å®çæ¯privateå±æ§ãç¶åå¨æ¨¡åä¸æä¸ä¸ªå ¨å±ç¨åºtestè¦è°ç¨å ¶è¿ä¸ªåè¿ç¨ï¼é£ä¹å°±ä¼åºç°è¿ç§é误ãæ´æ¹æ¹æ³ï¼å°è¿ä¸ªåè¿ç¨è®¾ç½®æå ¨å±çï¼publicï¼ï¼å¹¶æ¾å¨æ¨¡åä¸ï¼è¿æ ·å°±å¯ä»¥è§£å³äºã
所有的Range前要加上ActiveDocument.本回答被提问者采纳
ThisWorkbook.Application.Caption = APP_NAME_STR
CreateTableMenu
End Sub
Sub CreateTableMenu()
DeleteTableMenu
MenuBars(xlWorksheet).Menus.Add (MENU_REPORT_STR)
MenuBars(xlWorksheet).Menus(MENU_REPORT_STR).MenuItems.Add Caption:=MENU_REPORT_HISTDATA_SEARCH_STR, OnAction:="FormShow"
End Sub
Sub DeleteTableMenu()
On Error Resume Next
MenuBars(xlWorksheet).Menus(MENU_REPORT_STR).MenuItems(MENU_REPORT_HISTDATA_SEARCH_STR).Delete
On Error Resume Next
MenuBars(xlWorksheet).Menus(MENU_REPORT_STR).Delete
On Error Resume Next
End Sub
Sub FormShow()
UserForm2.Show
End Sub
Function ChangeDate(ByVal OldDate As String) As String
Dim DateLen, i As Long
Dim ss, EndDate As String
Dim mas As Integer
EndDate = ""
DateLen = Len(OldDate)
For i = 0 To DateLen - 1
ss = Mid$(OldDate, i + 1, 1)
mas = Asc(ss)
If mas <> 0 Then
EndDate = EndDate + ss
End If
Next i
ChangeDate = EndDate
End Function
Function GetVBString(ByVal OldStr As String) As String
Dim nLen, i As Long
Dim ss, strRet As String
Dim mas As Integer
Dim nSpacePos As Integer
nLen = Len(OldStr)
nSpacePos = nLen
For i = 0 To nLen - 1
ss = Mid$(OldStr, i + 1, 1)
mas = Asc(ss)
If mas = 0 Then
nSpacePos = i
Exit For
End If
Next i
GetVBString = Left(OldStr, nSpacePos)
End Function本回答被网友采纳