我正在使用1XXX单词文档,我想使用vbs更快地更改复选框的状态但是我找不到任何工作解决方案,之后,我想知道查找和替换是否可以解决我的问题,所以我为此写了一些代码
Const wdReplaceAll = 2
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("C:\checkbox.doc")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Find.Text = "@1"
objSelection.Find.Forward = TRUE
objSelection.Find.MatchWholeWord = TRUE
objSelection.Find.Replacement.Text = objSelection.InsertSymbol 253, "Wingdings"
objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll
但是,它无法正常工作,并始终在objSelection.InsertSymbol 253上显示错误......
答案 0 :(得分:0)
您不能在此类作业中使用InsertSymbol
。将搜索文本替换为格式为“Wingdings”的适当字符:
With objSelection.Find
.Text = "@1"
.Replacement.Text = ChrW(61693)
.Replacement.Font.Name = "Wingdings"
...
End With
objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll
或仅Find
搜索文本,然后在选择中使用InsertSymbol
:
objSelection.Find.Text = "@1"
objSelection.Find.Execute
objSelection.InsertSymbol 253, "Wingdings"