Open and run A Macro in Word from Access

Curry

Registered User.
Local time
Tomorrow, 02:54
Joined
Jul 21, 2003
Messages
73
Hi All.

Below is a command which will open up word from some Code that I have in a form. I would like a saved word macro to run when opening.

Is there anything I can add to this command to run the Macro straight away?

RetVal = Shell("C:\program files\microsoft office\office\winword.exe", 1)

Thanks
IC
 
What if you established a template in word with the macro fireing on open? Then change your line to target the template
RetVal = Shell("C:\program files\microsoft office\office\templates\mytemplate", 1)

Just a thought...
 
Thanks for that....I gave this a go however the command

RetVal = Shell("C:\program files\microsoft office\office\templates\mytemplate

doesn't seem to work for a .DOT file only for Winword .Exe.

IC
 
How about putting the macro in access and run from there after opening the word document?

eg

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
appWord.Visible = True
appWord.displayalerts = False
appWord.Documents.Open FileName:="c:\personal\02-03 KDDPS Supplier.doc", _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto

now run the macro here:
appWord.Selection.WholeStory
appWord.Selection.Copy
etc etc


Paul.
 
I forgot:

make sure you add Microsoft Word to the Reference library or it won't work.
 
This is fantastic...I had got it working however i still had some issues....I think doing it this way will resolve them for me.


Thanks for your help.

IC
 

Users who are viewing this thread

Back
Top Bottom