View Single Post
Old 06-17-2009   #2 (permalink)
Joe Fawcett


 
 

Re: New to VBscript, Help please!

That code is VBA, not VBScript. VBScript does not support named arguments
(e.g. FileName :=)
You will also need to define the constants such as wdReplaceAll.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"yu" <zhangyu05@xxxxxx> wrote in message
news:788627e9-c322-48f6-b216-b6bcf813dd7b@xxxxxx
Quote:

> Dear All,
>
> It is my first time to write a Vb script to automate Word document
> processing. What I am trying to accompish is to find a specific
> keyword, then Bold it. the keyword will be appearing many times in the
> WORD document. here is what I have tried. the script is runing with
> error. but no change was made to document.
> can someone kindly point out what is wrong?
>
> Thank you!
>
> Yu
>
> ------------------------test.vbs--------------------------------
>
> Set ObjWord = createobject("Word.Application")
> Set ObjWdDoc = ObjWord.Documents.Open(FileName:="c:\test.doc")
> ObjWord.Visible = True
> Set ObjWdRange = ObjWdDoc.Content
> With ObjWdRange.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = "Randomized ID:"
> .MatchCase = True
> With .Replacement.Font
> .Bold = True
> End With
> .Execute wdReplaceAll
> End With
>


My System SpecsSystem Spec