然后我使用创建对象打开了 MS 单词,我必须搜索一个单词并将其替换为一个表。我能够使用 VBA 构建一个表。但是,我需要用表格替换那个词(匹配),然后根据单元格填充表格。这是我的代码:-
Dim MyApp As New Word.Application
Dim MyDoc As Word.Document
Set MyDoc = MyApp.Documents.Add
MyApp.Visible = True
MyDoc.Activate
With ActiveDocument.Content.Find
.Text = "blue"
.Forward = True
.Execute
If .Found = True Then .Parent.Bold = True
End With
MyApp.ActiveDocument.Tables.Add Range:=MyApp.Selection.Range, numrows:=5, numcolumns:=5
MyApp.ActiveDocument.Save
MyApp.Quit