|
本帖最后由 约定的童话 于 2020-4-18 09:45 编辑
昨天刚弄了一道word的题,查不到资料,愣是一个个试了出来,花了三个多小时
Sub 添加重点()
Application.ScreenUpdating = False
Dim i, arr, Word As Object
Set Word = VBA.CreateObject("word.application")
Word.Visible = 0
arr = [a1].CurrentRegion
For i = 2 To UBound(arr)
Set MyWord = Word.Documents.Open(ThisWorkbook.Path & "\" & "教材原始文件.doc")
Word.Selection.Find.ClearFormatting '全选文字
With Word.Selection.Find '开启查找
.Text = arr(i, 1) '输入查找关键词
End With
Word.Selection.Find.Execute '选择关键词
Word.Selection.Comments.Add Range:=Word.Selection.Range '打开批注框
Word.Selection.TypeText Text:=arr(i, 2) '添加
Word.Documents.Close True
Next
Word.Application.Quit
Set MyWord = Nothing
MsgBox "添加完毕!"
End Sub
|
评分
-
1
查看全部评分
-
|