Word Object model for VBScript

L

Les

Hi,

I am trying to automate WORD via VBScript and cannot find references to the
word object model as could be used from VBScript. I can find it for VB, but
this is not sufficient to find out the order of parameters for example, or
what the properties and methods I can use are.

For example copying a line from VBA for opening a file (with slight
modifications) is:
Set Doc = oWord.Documents.Open (FileName:="2004CGC.TXT",
ConfirmConversions:=True, ReadOnly:=False, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, Encoding:=1252)

BUT

I cannot use parameter names in VBScript and do not know what the order of
parameters should be.

Also I'd like to know what parameters I could use to open a TXT document and
then save that as a WORD document.

Do you know of any reference that I can use to give me that information?

Any help is most appreciated.

Cheers,
Les
 
J

Jay Freedman

Hi,

I am trying to automate WORD via VBScript and cannot find references to the
word object model as could be used from VBScript. I can find it for VB, but
this is not sufficient to find out the order of parameters for example, or
what the properties and methods I can use are.

For example copying a line from VBA for opening a file (with slight
modifications) is:
Set Doc = oWord.Documents.Open (FileName:="2004CGC.TXT",
ConfirmConversions:=True, ReadOnly:=False, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, Encoding:=1252)

BUT

I cannot use parameter names in VBScript and do not know what the order of
parameters should be.

Also I'd like to know what parameters I could use to open a TXT document and
then save that as a WORD document.

Do you know of any reference that I can use to give me that information?

Any help is most appreciated.

Cheers,
Les

Hi Les,

All the pieces of the Word object model are documented in the Word VBA
help system.

For each method, look in the Word VBA help topic for that method (most
easily by typing the method name in the code window and pressing F1).
The parameters are always listed in the order needed for passing
parameters by position.

You'll also need the numerical values of constants such as
wdOpenFormatAuto. To get those, open the Word VBA editor and pres F2
to open the Object browser; then search for the constant's name. The
numerical value will be shown at the bottom of the window.

For example, wdOpenFormatAuto = 0, or you could use wdOpenFormatText =
4. To save the document as a Word document, use the constant
wdSaveFormatDocument, which also is 0, in the second parameter of the
ActiveDocument.SaveAs method.
 
J

Jonathan West

Hi Les,

To supplement Jay's reply, the order of the parameters is the order in
whiuch they are documented in the relevant entry in the Word VBA help file.
There may be one or two places where they goofed, but in almost all cases
you can rely on this.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
L

Les

Hi,

Thanks Jay and jonothan, with your help (and some from others too) I was
able to complete my code. One other place I was pointed to, was to a WebCast
by the Scripting Guys at
http://www.microsoft.com/technet/scriptcenter/hubs/office.mspx

This is the main page for Office. At the bottom of the page is a pointer to
the webcast about scripting the Office object model.

I also used the object browser in VB to help, but I suspect that would be
identical to that in VBA (and VBA is much more convenient).

Thanks very much for your help.

Cheers,
Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top