Trying to automate several Word tasks in VB6

K

Keith

Hi,

I've got a Word Doc that I'm using as a template for a mail merge
(MyTemplate.Doc). I'm using a text file for the data records (MyData.txt).
I need to automate the following tasks:

1. Open MyTemplate.Doc
2. Select a specific printer (HP LJ 9050DN PCL 6)
3. Set the page size to 11X17
4. Set the duplexing to Vertical
5. Set the Orientation to Landscape
6. Perform the Mail Merge
7. Print the newly merged document
8. Save the newly merged document using a filename parameter supplied by VB
9. Close both documents

I've been able to perform some of the above tasks (1, 6, 9) but I could use
some help on the others. Thanks for any help.

Keith
 
P

Peter Aitken

Keith said:
Hi,

I've got a Word Doc that I'm using as a template for a mail merge
(MyTemplate.Doc). I'm using a text file for the data records
(MyData.txt).
I need to automate the following tasks:

1. Open MyTemplate.Doc
2. Select a specific printer (HP LJ 9050DN PCL 6)
3. Set the page size to 11X17
4. Set the duplexing to Vertical
5. Set the Orientation to Landscape
6. Perform the Mail Merge
7. Print the newly merged document
8. Save the newly merged document using a filename parameter supplied by
VB
9. Close both documents

I've been able to perform some of the above tasks (1, 6, 9) but I could
use
some help on the others. Thanks for any help.

Keith

The easiest way is to perform the desired steps with the macro recorder
turned on. Then you can look at the recorded code and make any needed
changes.
 
D

Doug Robbins

The page size and orientation should be set in the template and not require
setting via code.

See the article "How to do a mail merge to the printer using VBA, without
displaying the Print dialog" at:

http://word.mvps.org/FAQs/MailMerge/MergeStraightToPrintrWVBA.htm

Also check the mailmerge function in the visual basic editor to learn the
context and method of using it.

Also see the article "Changing the selected (current) printer in Word
without changing
the system default printer" at:

http://word.mvps.org/FAQs/MacrosVBA/ChangeCurPrinter.htm

--
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
 

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