问题描述
我有以下宏可以用单独的 Excel 文件中列出的单词替换 Word 文档中的单词。
Function ListfindAndReplace1()
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object
Dim i As Integer,j As Integer
Dim lastRow As Integer
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open("E:\DropBox\Dictionaries\zJTA.xlsx")
Set xlWS = xlWB.Worksheets("Sheet1")
lastRow = xlWS.UsedRange.SpecialCells(xlCellTypeLastCell).Row
For i = 1 To ThisDocument.Words.Count - 1 Step 1
For j = 1 To lastRow Step 1
ThisDocument.Words(i) = Replace(ThisDocument.Words(i),xlWS.Cells(j,1).Value,2).Value)
Next j
Next i
Set xlWS = nothing
xlWB.Close True
Set xlWB = nothing
xlApp.Quit
Set xlApp = nothing
End Function
当我运行宏时,以下几行出现错误消息“运行时错误 1004:无法获取范围类的 SpecialCell 属性”
lastRow = xlWS.UsedRange.SpecialCells(xlCellTypeLastCell).Row
我尝试了很多东西,但没有用。请帮忙。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)