Open Word and run macro

C

ckxplus

Hello,

I'm looking for a way to open Word from an external program and then
run a macro. This can be done with "[path]\winword" /mMymacro.
Unfortunately, "Mymacro" must must be public for this to work and I'd
rather not have it on the list of macros you get with Alt-F8.

Is there a way to run a private macro or a macro with arguments at
startup? Alternatively, can I determine whether a macro is being run at
startup and if not, issue a warning?

Advance thanks,
John Hendrickx
 
S

Steve Yandl

John,

Here is a sample of a vbScript I use that might get you started.

_______________________________

' Runs a VBA subroutine named myMacroA stored in a module belonging to
' the Microsoft Word template C:\Test\myVBA.dot.
' Full path to the dot file is required if it isn't stored in the default
templates folder
' Steve Yandl

Set objWdApp = CreateObject("Word.Application")
objWdApp.Visible = True
objWdApp.Documents.Add("C:\Test\myVBA.dot")
objWdApp.Run "myMacroA"
_______________________________

Steve Yandl
 
C

ckxplus

What I want to do is to merge a set of files (text, rtf or graphics)
created by the statistical package SAS and then format the results.
I've written the VBA macros that will do this but I'd like to be able
to automate the process directly from SAS. Calling a macro with the /m
option would be a simple solution but that would mean that the macros
would be visible in Word and that could cause confusion. The thing is,
there would have to be two versions of some macros, one to run from
Word, with dialog boxes to specify the location of the files, and one
called from SAS, where the file location is already known.

What I'm thinking of doing is using AutoIT to start Word and run the
macros. Doesn't look too complicated, and this has the advantage that
there's just one set of Word macros.

Best,
John Hendrickx
 

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