Using Excel VBA strings in Word macro?

E

Ed

I'd like to use a command button in an Excel document to open a Word
document which has a macro that runss when the document opens. Can I, as
part of the code behind the Excel button, dim cell values as strings that
can be used by the Word macro? For example, the user enters a text value in
an Excel cell; when the button is clicked, the Excel code dims that value as
a string, launches Word and opens a document, and the macro in the document
picks up that string as a "search for this" parameter.

Ed
 
C

Cindy Meister -WordMVP-

Hi Ed,
I'd like to use a command button in an Excel document to open a Word
document which has a macro that runss when the document opens. Can I, as
part of the code behind the Excel button, dim cell values as strings that
can be used by the Word macro? For example, the user enters a text value in
an Excel cell; when the button is clicked, the Excel code dims that value as
a string, launches Word and opens a document, and the macro in the document
picks up that string as a "search for this" parameter.
Not directly with an AutoOpen macro, no.

If your code were to open the Word document, then call a macro in the document
using Application.Run, and if this isn't Word97, then you can pass arguments
to the macro as part of Application.Run

Under every other circumstance you'd need to write the data somewhere, like to
a text file on disk.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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