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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to access word mac

Status
Not open for further replies.

jjames

Programmer
Mar 13, 2001
212

Is there a way to access word macros through the Word Object Model. Any help is appreciated. Thanks.
 
what are you wanting to do???

you can open Word and a documant and run a macro in one command line like so:

' Launches Word and opens a specified document
' And runs an optional macro. the macro could print out the word doc and quit

Dim retval As Variant
Dim DocName, MacroName As String
' Drive and Full path to name and location of Word document
DocName = "F:\Somefolder\MyDoc.doc"

'Optional Macro Name. Note Word Macro name cannot have any spaces in it.
'MacroName = "/M" & "MacroName"

'Note full path to Word including Drive and folder
retval = Shell("c:\Microsoft Office97\Office\WinWord.exe" & " " & DocName & MacroName, vbNormalFocus)


DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 

Thank you for your response. I was looking more at how to display existing macros in a word document through VB. Also, can you tell me if when you reference a word document in VB ie:

Set objDocument = objWord.OpenDocument("SomeWordFile")

will this run any macros in that word file?

Thank You.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top