Arguments (I think that is what they are called)

G

Greg Maxey

Is there a way of finding a list of the various arguments a method can have.
I stumbled around for over an hour the other day trying to find the correct
"=wdDoNotSaveChanges" to replace "wdPromtToSaveChanges" found in the
following VBA Help example for the Close method.

ActiveDocument.Close _
SaveChanges:=wdPromptToSaveChanges, _
OriginalFormat:=wdPromptUser

Since there doesn't appear to be a auto suggestion feature for these
"wd...." type elements and the help file only listed this one example, how
do you learn what works other than repeated guessing at what might work?

Thanks.
 
P

Peter Hewett

Hi Greg Maxey

Absolutely! The first thing is to make sure you have the VBA help files installed. From
within the VBA IDE you can then select the word "Close" from ActiveDocument.Close and
press F1. On the system I've currently got booted (Word 2003) I get the following info
from the helpfile:

Closes the specified document or documents.

expression.Close(SaveChanges, OriginalFormat, RouteDocument)
expression Required. An expression that returns one of the above objects.

SaveChanges Optional Variant. Specifies the save action for the document. Can be one of
the following WdSaveOptions constants: wdDoNotSaveChanges, wdPromptToSaveChanges, or
wdSaveChanges.

OriginalFormat Optional Variant. Specifies the save format for the document. Can be one
of the following WdOriginalFormat constants: wdOriginalDocumentFormat, wdPromptUser, or
wdWordDocument.

RouteDocument Optional Variant. True to route the document to the next recipient. If the
document doesn't have a routing slip attached, this argument is ignored.



Also, you can use the ObjectBrowser (F2). You can then browse to Document, Close. In the
pane at the bottom of the window it will display:

Sub Close([SaveChanges], [OriginalFormat], [RouteDocument])
Member of Word.Document



The online help is the most helpful as it informs you that the parameter SaveChanges is an
Enum of type WdSaveOptions. WdSaveOptions has the following constants defined for it
wdDoNotSaveChanges, wdPromptToSaveChanges and wdSaveChanges.

You should use the names (wdDoNotSaveChanges, wdPromptToSaveChanges or wdSaveChanges)
rather than try to find and use their numeric value. The whole point of an Enum is that
it generates a list of named constants that makes the code more comprehensible.

Me thinks you would find it extremely useful to purchase a book on VBA or VB!

HTH + Cheers - Peter
 
J

Jay Freedman

Hi Greg,

Here are two ways, depending on what information you have to start
with...

- Put the cursor on the name of the method whose arguments you want,
in this case Close, and press F1. This should take you to the topic on
the syntax of the method (not the example, which is often fluff).
There should be a list of all the arguments, each with a list of
values -- sometimes spelled out, sometimes as a link that expands when
clicked. For (document).Close, I see this:
-----
SaveChanges Optional Variant. Specifies the save action for the
document. Can be one of the following WdSaveOptions constants:
wdDoNotSaveChanges, wdPromptToSaveChanges, or wdSaveChanges.
-----

- Press F2 to open the Object Browser. In the search box, type any
part of any constant you already know -- for example, SaveChanges --
and click the binoculars button. This will give you a list of all the
identifiers in VBA that contain that string anywhere in their names.
Also, constants are generally members of collections, in this case,
the WdSaveOptions collection, and selecting one in the list of found
items will cause the bottom window to show the entire collection.

Another nice part of the Object Browser is that it will show you the
numeric values of the named constants. This is useful when you're
programming Office automation in VB or another language using late
binding, when the app doesn't have the definitions of the constants at
design time.
 
G

Greg Maxey

Peter,

I have Help installed, I just wasn't drilling down far enough. I found the
information that you mentioned. Thank you.

You are not the first to suggest I buy a book. I have a recommendation
(can't think of it right now) that I will look for next chance I get.

I have also been reading the Office 97 Programer's Guide as it relates to
Word.

--
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in (e-mail address removed)

Peter said:
Hi Greg Maxey

Absolutely! The first thing is to make sure you have the VBA help
files installed. From within the VBA IDE you can then select the
word "Close" from ActiveDocument.Close and press F1. On the system
I've currently got booted (Word 2003) I get the following info from
the helpfile:

Closes the specified document or documents.

expression.Close(SaveChanges, OriginalFormat, RouteDocument)
expression Required. An expression that returns one of the above
objects.

SaveChanges Optional Variant. Specifies the save action for the
document. Can be one of the following WdSaveOptions constants:
wdDoNotSaveChanges, wdPromptToSaveChanges, or wdSaveChanges.

OriginalFormat Optional Variant. Specifies the save format for the
document. Can be one of the following WdOriginalFormat constants:
wdOriginalDocumentFormat, wdPromptUser, or wdWordDocument.

RouteDocument Optional Variant. True to route the document to the
next recipient. If the document doesn't have a routing slip attached,
this argument is ignored.



Also, you can use the ObjectBrowser (F2). You can then browse to
Document, Close. In the pane at the bottom of the window it will
display:

Sub Close([SaveChanges], [OriginalFormat], [RouteDocument])
Member of Word.Document



The online help is the most helpful as it informs you that the
parameter SaveChanges is an Enum of type WdSaveOptions.
WdSaveOptions has the following constants defined for it
wdDoNotSaveChanges, wdPromptToSaveChanges and wdSaveChanges.

You should use the names (wdDoNotSaveChanges, wdPromptToSaveChanges
or wdSaveChanges) rather than try to find and use their numeric
value. The whole point of an Enum is that it generates a list of
named constants that makes the code more comprehensible.

Me thinks you would find it extremely useful to purchase a book on
VBA or VB!

HTH + Cheers - Peter


Is there a way of finding a list of the various arguments a method
can have.
I stumbled around for over an hour the other day trying to find the
correct "=wdDoNotSaveChanges" to replace "wdPromtToSaveChanges"
found in the
following VBA Help example for the Close method.

ActiveDocument.Close _
SaveChanges:=wdPromptToSaveChanges, _
OriginalFormat:=wdPromptUser

Since there doesn't appear to be a auto suggestion feature for these
"wd...." type elements and the help file only listed this one
example, how
do you learn what works other than repeated guessing at what might
work?

Thanks.
 

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

Top