find and replace symbol using vbs

Hi Expert,

I am working a 1XXX words documents, I want to use vbs to changing the status of checkbox faster but I can't found any work solution, after that, i wonder if find and replace can solve my issue, so i wrote some code for this

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
But, it can't work, and always show the error on the objSelection.InsertSymbol 253, can anyone advice me how to do it A.S.A.P?

Any help on above is really appreciated.
Last updated:6/20/2013 5:19:27 AM

1 Answers

Vijay Shukla
Vijay Shukla

Hi Expert,

You can't use InsertSymbol in an assignment like that. Either replace the search text with an appropriate character formatted as 'Wingdings': With objSelection.Find

  .Text = '@1'
  .Replacement.Text = ChrW(61693)
  .Replacement.Font.Name = 'Wingdings'
End With

objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll
or just Find the search text and then use InsertSymbol on the selection:

objSelection.Find.Text = '@1'

objSelection.InsertSymbol 253, 'Wingdings'

I hope it helpful for you.