任何人都可以告诉我,如何在word文档中找到一个特定的单词并使用vba代码粘贴一个单词?
我已经打开了这个文件。所以我只是想找到这个单词并在附近粘贴一个单词。我使用moveown和moveright方法完成了这个特定的单词。但它更依赖于光标的位置。
谢谢,
Bharathi
答案 0 :(得分:0)
我在访问中使用它我不知道它是否适合你。
Dim mWord As Word.Application
Dim mDoc As Word.Document
Dim mRange As Word.Range
Set mDoc = mWord.Documents.Open("YourPath")
mDoc.SaveAs "Where you want to save"
Set mWord = New Word.Application
mWord.Visible = False
DoEvents
Set mRange = mWord.ActiveDocument.Content
mRange.Find.Execute FindText:=TextToFind1, ReplaceWith:=TextToFind1 & TextToReplace1, Replace:=wdReplaceAll
mRange.Find.Execute FindText:="TextToFind2", ReplaceWith:="TextToReplace2", Replace:=wdReplaceAll
Set mRange = Nothing
mDoc.Save
'Display
mWord.Visible = True
Shell "Explorer.exe /n,/e," & "DirectoryToOpen", vbNormalFocus
祝你好运