Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object commands 3

Status
Not open for further replies.

GShen

MIS
Sep 26, 2002
561
0
0
US
I found some code to create and object for printing a WORD and EXCEL document.
I have found bits and pieces of the options from multiple websites.
Is there a list (Anywhere) of all the possible commands.

eg
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open RptToPrint
WordObj.ActiveDocument.pagesetup.PaperSize = 2 'Set to letter size
WordObj.ActiveDocument.Save
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing

When you do it in excel it has different syntax options to perform the same function.

It can drive you crazy.

Is there anyplace where I can get all the options?
When you type in WordObj. it does not give you all the options.

Thanks.

Remember when... everything worked and there was a reason for it?
 
When in the application's VBE (Alt-F11) use the F2 (object browser) and F1 (VBA help) keys.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
When you're automating, there's basically two methods, one is called late binding, in which case there is no reference to the automtated application, and no "knowledge" of it in the automating application.

The other, which is called early binding, means you set a reference to the automated application (Tools | References), and declare the objects explicitly

Dim o as Word.Application
Dim d as Word.Document
...

In the latter case, you'll get "intellisence" when working with the objects, and you'll find help in the help file, Object Browser etc.

Downside is problems if the users have different versions.

Roy-Vidar
 
With Excel you can also record a macro (not so much with Word, the macros can be quite flaky) of yourself doing actions and then the code is available for you to see in the VBE. You'll have to cut out some of the unnecessary code that Excel puts in but that's not too much work at all.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Ok,
Here is what I got and part of it is my lack of knowledge with the object browser.
I am in the module. I clicked on object browser.
There are 2 blank drop downs in the upper left hand corner.
The 1st has libraries, so I clicked on VBA.
The 2nd drop down is blank.
I typed in Object and hit the search. It came up with a bunch of stuff which is useless to me. Obviously I am doing something wrong. I saw a bunch of classes come up but what do I do from here? Because from what you are telling me, it should show me all the paramaaters of the object I am trying to reference.
eg. WordObj.Quit or Wordobj.??????????


Remember when... everything worked and there was a reason for it?
 
If you've added a reference to the Microsoft Word X.0 Object Library (as per Roy's post) when you go into the object browser the top dropdown will have Word in it, that's what you need to look at.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
thanks all,

I added the reference of WORD and EXCEL. That was a small problem. LOL.

I am fine for now.

Stars for everyone.

Remember when... everything worked and there was a reason for it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top