Home > DeveloperSection > Forums > find and replace symbol using vbs
Jayden Bell
Jayden Bell

Total Post:105

Posted on    June-20-2013 1:46 AM

 VB Script VB Script 

 1 Reply(s)
 977  View(s)
Rate this:
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.

Vijay Shukla

Total Post:100

Posted on    June-20-2013 5:19 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick