Printout problem

  • Thread starter Günter Brandstätter
  • Start date
G

Günter Brandstätter

Hi all,
if want to print a range of pages by code, it will not work.
I use
objWord.ActiveDocument.PrintOut True, Range:=wdPrintFromTo, From:=FromPage,
To:=ToPage

even with the Pages-Argument in this line and Range:=wdPrintRangeOfPages
my printer rests quiet.

Can anyone tell me why?
any answer appreciated
Günter
 
P

Peter Hewett

Hi Gunther

The code snippet looks ok. I'd check that Word is using the printer you
expect, try:

objWord.ActivePrinter

if it's not correct you can use :

ActivePrinter = "Your printer name here"

This code will however also change the system dafault printer! If you want to
just select a printer WITHOUT changinging the default printer check out the
code at this URL:
http://word.mvps.org/FAQs/MacrosVBA/ChangeCurPrinter.htm

HTH + Cheers - Peter
 
G

Günter Brandstätter

Hi Peter,
I tried that also, if I look in the print queue, I see the document for a
short time, but with a size of 400 bytes only, and it disappears. So
something must be wrong with the statement.
thanks for your answer anyway
Günter
 
P

Peter Hewett

Hi Gunther

Add a break point to your code at the line you execute your
"objWord.ActiveDocument.PrintOut" statement.

Try statements like, from the VB/VBA IDE Immediate window:
objWord.ActiveDocument.PrintOut False, Range:=wdPrintFromTo, From:=1, To:=1

The above disables background printing for the documentand prints just page
1. Try a few other variants and see what happens.

HTH + Cheers - Peter
 
G

Günter Brandstätter

Hi Peter,
I tried what you said and now I know which causes my problem. The program
wants to print the original document with the mailmerge-fields which in fact
consists of one page only and not the merged document, which has many pages.
I don't know why, but even the command
objWord.Documents(1).PrintOut False, Range:=wdPrintFromTo, From:="2",
To:="2"
does not do the job. I'm lost somehow, as I don't know what causes Word to
print the original document every time.

Thanks again
Günter
 
G

Günter Brandstätter

Hi Peter,
I went a little bit deeper in to my problem. I saved the mail-merged
document as a file and tried to printout the page 2 with Word's
printer-dialog. Guess what happened? Nothing! It does not print. Now I
removed the "New section" from the end of each page, which is inserted
automatically by Word's mailmerge function, and - voilà - now my printout
works.
Can I also remove these "New sections" programmatically ?

thanks
Günter
 
G

Günter Brandstätter

Hi Peter,

thank you for your answer, I did the same thing in my solution. The only
inconvenience is when you print several pages, you have to select and print
each page separately.
Thanks again and have a good day
Günter
 

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