Macro opening Word document

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I have an Access 2000 db linked to Word 2000 documents
with merge fields and Word logic fields. On a form in
the db users can click command buttons and open
corresponding linked Word forms. The command buttons
trigger corresponding macros. An example of the command
line in the
RunApp macros triggered by the command button is as
follows:

C:\Program Files\Microsoft
Office\Office\winword.exe "C:\PBdB11162001\Pleadings
(merge)\VoucherSheets.doc"

Is there code I can add to the macro that will cause the
Word doc not only to open, but to merge? Or do I need to
tackle this another way, such as from within Word.

Thank you.

Jim
 
You will probably be best served having part of the solution in Word,
whether it be a macro you have created in Word that you fire off through the
command line you launch from Access, or whether it's VBA code that you write
behind your word document that happens onLoad/onOpen.
 
WORDPATH\winword.exe /mMACRONAME
I should note, just to be clear, that this macro will take the place of the
autoexec macro running at launch, so if you are depending on an autoexec
macro to run as well when you open this document, it won't using this
technique.
 
Sorry, but do not understand where to place /mMACRONAME.
My RunApp Condition is: C:\Program Files\Microsoft
Office\Office\WINWORD.EXE "C:\Documents and
Settings\SteinbeT\My Documents\Teds Stuff\Access 2000
\Church DB\Welcome Letter.doc"; and it does open up Word.
I have a macro named "MergeIt" which works, but am not
cannot get to work with condition.
Thanks for help,
teds
 
Try this:
C:\Program Files\Microsoft Office\Office\WINWORD.EXE /mMergeIt "C:\Documents
and Settings\SteinbeT\My Documents\Teds Stuff\Access 2000\Church DB\Welcome
Letter.doc"
 
Tried your ....WINWORD.EXE /mMergeIt "C:....; but all it
did was open the document, not execute the MergeIt macro.
I also tried to not have a space between the EXE &
the /mMergeit, but it didn't work at all. Any other
suggestions?
Thanks for the help,
teds
-----Original Message-----
Try this:
C:\Program Files\Microsoft
Office\Office\WINWORD.EXE /mMergeIt "C:\Documents
 
I am interested in this answer too. personally my macro opens my doc,retrieves my data from my access query,merges it to my printer(prints it)and then closes my doc (actually I have 2 docs my letter and my mailing lables) I just want to launch my word macro from access which I can not figure out how to do because I can not figure out where word saved the darn macro to be able to enter the path in the command line
 
this all seems to depend on a person saving a macro file to disk---how do you do that ? When I record my macro it gives me the option of saving the macro in all documents or the current document. Do I point my path to the document its saved in? I also tried opening the macro in VB and exporting it to file but it saved it as a .bas which i didnt think would work but I tried it and it doesnt.
 
I just tested this and it works for me:

RunApp macro
Command Property =
winword.exe /mRunMeAtStart "C:\Documents and Settings\bryanreich\My
Documents\Doc10.doc"

The macro in MS Word "RunMeAtStart" fires when the document opens.
--
Bryan Reich
Microsoft Office
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


reesey said:
I am interested in this answer too. personally my macro opens my
doc,retrieves my data from my access query,merges it to my printer(prints
it)and then closes my doc (actually I have 2 docs my letter and my mailing
lables) I just want to launch my word macro from access which I can not
figure out how to do because I can not figure out where word saved the darn
macro to be able to enter the path in the command line
 
I tried this again ---I am doing this task by bringing up the toolbar,choosing a command button and then a wizard pops up, I choose run application and then in the next window try to put the command line in as you posted. When I try to execute the command button it comes up as a syntex error--You put run application macro in your post---I dont have a choice of run application macro, just run application. Is that my problem perhaps ?
 
I see what you're doing now, and I see why it's erroring. It's the quotes
around the file name.
This wizard actually builds the VBA code behind the button for you, but it
doesn't do it super intelligently. It just copies the command line you
provide verbatim, which in this case causes problems because the quotes mess
up the VBA syntax unless you go in and clean it up yourself. (it's easy, but
if you don't know VBA, it might be intimidating to touch the code)
My advice, don't use the wizard, just create the button. Then, go into it's
properties and set it's OnClick event to point to a macro that runs the
macro action I detailed in my previous post. The macro doesn't get confused
by the quotes.
--
Bryan Reich
Microsoft Office
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


reesey said:
I tried this again ---I am doing this task by bringing up the
toolbar,choosing a command button and then a wizard pops up, I choose run
application and then in the next window try to put the command line in as
you posted. When I try to execute the command button it comes up as a syntex
error--You put run application macro in your post---I dont have a choice of
run application macro, just run application. Is that my problem perhaps ?
 
I actually had tried to email you directly copying the VB code into the email for you to see--I thought it would be the easiest way to discuss this. I thought the code was fairly simple and short and I do understand it a little...but i would have never thought or known that the quoatation marks were what was messing it up..
fixing the code sounds easier then creating a macro to run the macro and a button to run the macro that runs the macro...lo
Should the command line be all one string ? Could I just take the quotes out ? I have learned most of what I know by taking already built databases -- picking a function that I like or want to copy and then going into design mode to see "what" make it work the way it does...this running a word macro from access is very interesting to me. So I hope I am not bugging you.
 
I am still not getting something--I have tried everything you sai
creating a macro with the action RunApp
command line c:program files\microsoft office\office\winword.exe/mmacroname--when I try to run it it tells me "a path to the application is invalid or a component of the application is missin
so I added the word doc making it look like c:program files\microsoft office\office\winword.exe/mmacroname "d:mydocuments\service certifications\serv cert letter.doc" - I get the same erro

I went back to trying to create the command button using the wizard and choosing "runapp" ,the my command line and going into the vb and playing with the line---I finally got it to stop giving me a syntex error but it pops up a box that looks much like the word macro manager and there are no macros to choose even---it seemed like progress but still not there--

I have tried looking this up in books,taking access on line courses--nothing gets into this type of thing...just kind of glossed over the things I figured out myself. Can you suggest an advanced online Access Class or should perhaps try to get some formal education in VB ? As you can tell i really love this stuff.
 
Your syntax problems involve the paths you wrote.

c:program files\microsoft office\office\winword.exe/mmacroname

First, because of the space in "program files", you may have to quote this
(that's why I quoted it in my example). Second, your path syntax is wrong
because you're missing a backslash after your hard drive symbol. Lastly, the
/m should come after a space after the .exe just to be safe. I'm not sure
how this command handles running it all together.

"C:\Program Files\Microsoft Office\Office\winword.exe" /mmacroname <- make
sure you are replacing this "macroname" with the macro name itself, right?

and you have similar syntax problems with your document path
"d:\mydocuments\service certifications\serv cert letter.doc"

See if that doesn't clear things up.
--
Bryan Reich
Microsoft Office
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Reesey said:
I am still not getting something--I have tried everything you said
creating a macro with the action RunApp,
command line c:program files\microsoft
office\office\winword.exe/mmacroname--when I try to run it it tells me "a
path to the application is invalid or a component of the application is
missing
so I added the word doc making it look like c:program files\microsoft
office\office\winword.exe/mmacroname "d:mydocuments\service
certifications\serv cert letter.doc" - I get the same error
I went back to trying to create the command button using the wizard and
choosing "runapp" ,the my command line and going into the vb and playing
with the line---I finally got it to stop giving me a syntex error but it
pops up a box that looks much like the word macro manager and there are no
macros to choose even---it seemed like progress but still not there---
I have tried looking this up in books,taking access on line
courses--nothing gets into this type of thing...just kind of glossed over
the things I figured out myself. Can you suggest an advanced online Access
Class or should perhaps try to get some formal education in VB ? As you can
tell i really love this stuff.
 
thank you I will try this---I appreciate the help you are giving me. I want you to know that I am trying to get some VB education right away.
 
Back
Top