Fill in fields with parameters values from macro?!

W

Webtechie

Hello,

I have three letters that I need to send out on a regular basis. I want to
have an Office application (Excel) call the word document and fill in the
Company name and address.

I need to have a Word VBA macro that can receive parameters and then
substitute them in a document. I know Excel VBA very well, but not sure how
to do this in Word.

Question
======
How do you write a Word VBA Macro that can receive parameters and then
subtitute fields in a document with the parameter values?

For example:
(Word VBA)

Sub ChangeAddress(byRef CompanyName as string, Address as string, city as
string, st as string, zip as string)

--Open the Word Document
--Take these parameters and substitute them in the Word document.
--Close the Word Document

End Sub


Thank you.

Tony
 
D

Doug Robbins - Word MVP

See the article "Control Word from Excel†at:

http://www.word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm

Use a DOCVARIABLE field in the document (probably should be a template) in
the locations where you want the data to appear and have your code set the
..Value of corresponding variables in the document to the values that you
want to be displayed in the document and update the fields so that the value
are displayed.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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