We need to automate the creation of word documents from the command line. We
taught about creating a vbscript script that would take command line
arguments and create the word document according to those parameters.

For some reason, certain things work, otheres do not. When we try to call
some word.application or word.document methods, the script interpreters
gives an error.

Ex: Trying to run the following script by double clicking on its .vbs file
gives the following error (Translated from french):

Script: C:\insert.vbs
Line: 12
Caract: 33
Error: ')' expected
Code: 800A03EE
Source: MS vbscript compilation error

Sub FindBMark()

Dim wordApp ' As Word.Application
Dim wordDoc ' As Word.Document
Dim wordRange ' As Word.Range

Set wordApp = CreateObject("Word.Application")
Set wordDoc = wordApp.Documents.Open("C:\MyDoc.doc")

wordApp.Visible = True

wordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="City")
wordRange.InsertAfter "Quebec"

wordDoc.Save

wordApp.Quit

Set wordApp = Nothing

End Sub

Call FindBMark()

The script finds a bookmark called "city" in the document and insert the
word "Quebec" there...

If I code the script in a VBA macro (By uncommenting the 'AS
word.applicaton, etc), it works just fine. But the problem with the VBA
macros is that I can't seem to be able to call them from the command line or
pass parameters to them unattended.

I tried replacing the wdGoToBookmark by its value but it did not work either

RE: Manipulating Word 2000 from VBSCIPT script (WSH 5.6) by tlavedas

tlavedas
Thu Apr 29 16:16:03 CDT 2004

One problem is that 'named aurguments' are NOT supported in script for methods and functions. Rather, all arguments must be provided sequencially as expected by the function/method

That is ..

wordRange = wordDoc.Goto(wdGoToBookmark, "City"

Further, the explicit value for the system constants, like wdGoToBookmark, must be supplied, as in ..

Const wdGoToBookmark = -

Those are the only two problems I spotted in your sample code

Tom Laveda
========

----- G Dahler wrote: ----

We need to automate the creation of word documents from the command line. W
taught about creating a vbscript script that would take command lin
arguments and create the word document according to those parameters

For some reason, certain things work, otheres do not. When we try to cal
some word.application or word.document methods, the script interpreter
gives an error

Ex: Trying to run the following script by double clicking on its .vbs fil
gives the following error (Translated from french)

Script: C:\insert.vb
Line: 1
Caract: 3
Error: ')' expecte
Code: 800A03E
Source: MS vbscript compilation erro

Sub FindBMark(

Dim wordApp ' As Word.Applicatio
Dim wordDoc ' As Word.Documen
Dim wordRange ' As Word.Rang

Set wordApp = CreateObject("Word.Application"
Set wordDoc = wordApp.Documents.Open("C:\MyDoc.doc"

wordApp.Visible = Tru

wordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="City"
wordRange.InsertAfter "Quebec

wordDoc.Sav

wordApp.Qui

Set wordApp = Nothin

End Su

Call FindBMark(

The script finds a bookmark called "city" in the document and insert th
word "Quebec" there..

If I code the script in a VBA macro (By uncommenting the 'A
word.applicaton, etc), it works just fine. But the problem with the VB
macros is that I can't seem to be able to call them from the command line o
pass parameters to them unattended

I tried replacing the wdGoToBookmark by its value but it did not work eithe




Re: Manipulating Word 2000 from VBSCIPT script (WSH 5.6) by G

G
Fri Apr 30 08:09:12 CDT 2004


"Tom Lavedas" <tlavedas@hotmail.remove.com> a écrit dans le message de
news:F4FDC901-4F4F-4407-8644-2B4D0AA514B4@microsoft.com...
> One problem is that 'named aurguments' are NOT supported in script for
methods and functions. Rather, all arguments must be provided sequencially
as expected by the function/method.
>
> That is ...
>
> wordRange = wordDoc.Goto(wdGoToBookmark, "City")
>
> Further, the explicit value for the system constants, like wdGoToBookmark,
must be supplied, as in ...
>
> Const wdGoToBookmark = -1
>
> Those are the only two problems I spotted in your sample code.
>

Thanks Tom, it worked ! Also, please note that in order to go to the first
bookmark (Using wdGoToFirst constant=1), the "count" value must be 0, 1
tried 1, it did not work (specified bookmark not found)