VBScript Object heirarchy

I solved my initial question about why I couldn't get Word to save a plaintext file.

 oWord.Visible = TRUE
 oWord.Documents.Open(filename)
 oWord.Documents(filename).SaveAs newfilename, wdFormatText
 oWord.Quit

This didn't work because it had no idea what the heck wdFormatText was. After playing around and throwing some random vals in place of it, I managed to stumble across a value ( 2 ) that worked.

So now my question is, how do I create/declare the object that contains the enumeration so that I can use the wdFormatText instead of using this kludge? At the very least, does anyone have a link or something to details of the enumeration? The msdn site is deplorable when trying to look up that sort of detail on non-.NET technologies.

Thanks,
     - Natrous
LVL 1
NatrousAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leonstrykerCommented:
Basicly you need to Open the object browser and look up the numeric value of the constant.  In any MS Office application hit Alt + F11 to take yo to the VBA IDE and from there hit F2 to get you into the Object Browser.  Do a search on the constant to look up its value.

Leon
0
fantasy1001Commented:
Try this:
oWord.Documents(filename).SaveAs newfilename, fileFormat:=wdFormatDocument   'vba code

Thanks,
~ fantasy ~
0
NatrousAuthor Commented:
Leon - I tried doing what you said, but I couldn't find any objects that had the properties or enumerations I was looking for.

fantasy - VBScript doesn't like that syntax. (I've tried it already)

The main problem I'm having is that I am using vb script and not vb for apps and there's far less good documentation - as far as I can tell - about the former.

Thanks for the ideas,
 
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

leonstrykerCommented:
Then looking at the object browser I get the following for wdFormatText:

Const wdFormatText = 2
    Member of Word.WdSaveFormat

What can't you find?  What do you see in the object browser?

Leon
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fantasy1001Commented:
If you want better declaration, then just add the line
Const wdFormatText = 2 'at the top

'Usage
oWord.Documents(filename).SaveAs newfilename, wdFormatText

This is the one method people normally use.
~ fantasy ~
0
NatrousAuthor Commented:
Ok - my bad...
I finally found the right stuff in the object browser which is great in as much as I can be sure now that I'm saving in plain text as opposed to say, unicode. But, I still would like to be able to initialize, create, or otherwise reference the object by name instead of by using the raw number (which I can't figure out how to initialize in *VBScript* even with the object reference)

So.. if no one can help me find the full answer to my main question in another day or two, I'll give you part of the points for the help in finding the reference.

Thanks,
   - Natrous
0
NatrousAuthor Commented:
fantasy -
there must be some actual manner of getting access to the object itself instead of hard-coding it
0
leonstrykerCommented:
Natrous,

You are not really hard coding anything.  The constants you are using are just that, constants.  Somewhere along the line Microsoft designated that wdFormatText = 2, specifically for readability only.  In fact in both VB and VBA you could just as well use  the number 2 instead of wdFormatText and get exactly the same result.  In VBS you can make the same association yourself as fantasy1001 showed, but it is up to you to do so.  

That is one of the limitation of VBS, if you wish to go around it switch to VB or VBA.  Remeber VBS is subset of VBA, which is a subset of VB.  To get more functionality you need to move up the chain.

Leon
0
NatrousAuthor Commented:
Leon -

I understand what you are saying, but that is what i'm trying to get at. It is hard coding, because I actually need to choose a value. The idea behind VB trying to use all these objects is to create another layer of abstraction (for, among other things, readability). In all the different platforms, all of the constants are simply a number at heart that you can always choose to simply 'hard code' in. I realize all of this, but it is rather sloppy programming. Do I think that some newer release of the Windows Script Host will change the value of this particular enumeration from 2 to 4? Not really. But surrounded by so many other (albeit weak) object representations, it seems out of place and kludgy.

I assumed that since there were so many other objects open to use with VBScript, and since I can use the functions that are described in reference to these enumerations, I must be having some lack in syntax that I could not uncover. That was - and is - still my question. If in fact it is simply MSDN describing older functions with new references, then I am not entirely surprised. I was just trying to bring the level of the scripts as high as possible within the constraints of the system. Evidently I cannot use an object reference in this case, but at least now I will stop looking.

Thanks again for all the help,
 - Natrous
0
leonstrykerCommented:
Natrous,

I do not think we will see a much different version of WSH, in fact I would not be suprised if it will go away rather soon.  In its place we will be using full blown VB.NET.  ASP.NET has already dropped VBS and as far as M$ is concerned it is only the begining.

Leon
0
leonstrykerCommented:
Natrous,

I just noticed a file called ADOVBS.inc which looks like a list of constants for VBS to use.  It looks something like this;

<%
'--------------------------------------------------------------------
' Microsoft ADO
'
' Copyright (c) 1996-1998 Microsoft Corporation.
'
'
'
' ADO constants include file for VBScript
'
'--------------------------------------------------------------------

'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- CursorOptionEnum Values ----
Const adHoldRecords = &H00000100
Const adMovePrevious = &H00000200
'
' And so on
%>

I think you may be able to find or create a similar file for your Outlook VBS scripts and include the file for WSH to refernce it as it comes across those variables.  

Leon
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.