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

Re: Trying to automate several Word tasks in VB6 by Peter

Peter
Sat Jul 23 10:26:17 CDT 2005

"Keith" <Keith@discussions.microsoft.com> wrote in message
news:A3C79E99-38E4-480D-AD04-703677ACBA0C@microsoft.com...
> 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.


--
Peter Aitken

Remove the crap from my email address before using.



Re: Trying to automate several Word tasks in VB6 by Doug

Doug
Sat Jul 23 10:49:04 CDT 2005

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
"Peter Aitken" <paitken@CRAPnc.rr.com> wrote in message
news:Oh02hr5jFHA.1948@TK2MSFTNGP12.phx.gbl...
> "Keith" <Keith@discussions.microsoft.com> wrote in message
> news:A3C79E99-38E4-480D-AD04-703677ACBA0C@microsoft.com...
>> 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.
>
>
> --
> Peter Aitken
>
> Remove the crap from my email address before using.
>



Re: Trying to automate several Word tasks in VB6 by Jay

Jay
Sat Jul 23 14:22:51 CDT 2005

For step 4 (duplexing) and some of the others, see Jonathan West's
articles:
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=132

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

On Sat, 23 Jul 2005 17:49:04 +0200, "Doug Robbins"
<dkr@REMOVEmvps.org> wrote:

>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
>"Peter Aitken" <paitken@CRAPnc.rr.com> wrote in message
>news:Oh02hr5jFHA.1948@TK2MSFTNGP12.phx.gbl...
>> "Keith" <Keith@discussions.microsoft.com> wrote in message
>> news:A3C79E99-38E4-480D-AD04-703677ACBA0C@microsoft.com...
>>> 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.
>>
>>
>> --
>> Peter Aitken
>>
>> Remove the crap from my email address before using.
>>
>