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
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com

Re: Printout problem by Peter

Peter
Tue Jan 27 15:10:48 CST 2004

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ünter Brandstätter" <me@ho.me> wrote in news:O8nEufQ5DHA.2576
@TK2MSFTNGP11.phx.gbl:

> 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
> -------------------------------------------------------------------------
> FIGHT BACK AGAINST SPAM!
> Download Spam Inspector, the Award Winning Anti-Spam Filter
> http://mail.giantcompany.com
>
>
>
>


Re: Printout problem by Günter

Günter
Wed Jan 28 02:27:27 CST 2004

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



--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


"Peter Hewett" <Nospam@xtra.co.nz> a écrit dans le message de
news:Xns947E679024859Iwlpth@207.46.248.16...
> 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ünter Brandstätter" <me@ho.me> wrote in news:O8nEufQ5DHA.2576
> @TK2MSFTNGP11.phx.gbl:
>
> > 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
>
> -------------------------------------------------------------------------
> > FIGHT BACK AGAINST SPAM!
> > Download Spam Inspector, the Award Winning Anti-Spam Filter
> > http://mail.giantcompany.com
> >
> >
> >
> >
>



Re: Printout problem by Peter

Peter
Wed Jan 28 02:47:31 CST 2004

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ünter Brandstätter" <me@ho.me> wrote in news:#ivghiX5DHA.1968
@TK2MSFTNGP11.phx.gbl:

> From: "G?nter Brandst?tter" <me@ho.me>
> Subject: Re: Printout problem
> Newsgroups: microsoft.public.word.vba.general
>
> 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
>
>
>
> --
>
>
> -------------------------------------------------------------------------
> FIGHT BACK AGAINST SPAM!
> Download Spam Inspector, the Award Winning Anti-Spam Filter
> http://mail.giantcompany.com
>
>
> "Peter Hewett" <Nospam@xtra.co.nz> a ?crit dans le message de
> news:Xns947E679024859Iwlpth@207.46.248.16...
>> 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?nter Brandst?tter" <me@ho.me> wrote in news:O8nEufQ5DHA.2576
>> @TK2MSFTNGP11.phx.gbl:
>>
>> > 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
>


Re: Printout problem by Günter

Günter
Wed Jan 28 06:05:30 CST 2004

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

--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


"Peter Hewett" <Nospam@xtra.co.nz> a écrit dans le message de
news:Xns947EDDAEFCF59Iwlpth@207.46.248.16...
> 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ünter Brandstätter" <me@ho.me> wrote in news:#ivghiX5DHA.1968
> @TK2MSFTNGP11.phx.gbl:
>
> > From: "G?nter Brandst"tter" <me@ho.me>
> > Subject: Re: Printout problem
> > Newsgroups: microsoft.public.word.vba.general
> >
> > 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
> >
> >
> >
> > --
> >
> >
>
> -------------------------------------------------------------------------
> > FIGHT BACK AGAINST SPAM!
> > Download Spam Inspector, the Award Winning Anti-Spam Filter
> > http://mail.giantcompany.com
> >
> >
> > "Peter Hewett" <Nospam@xtra.co.nz> a ,crit dans le message de
> > news:Xns947E679024859Iwlpth@207.46.248.16...
> >> 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?nter Brandst"tter" <me@ho.me> wrote in news:O8nEufQ5DHA.2576
> >> @TK2MSFTNGP11.phx.gbl:
> >>
> >> > 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
> >
>



Re: Printout problem by Günter

Günter
Wed Jan 28 06:42:00 CST 2004

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


--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


"Peter Hewett" <Nospam@xtra.co.nz> a écrit dans le message de
news:Xns947EDDAEFCF59Iwlpth@207.46.248.16...
> 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ünter Brandstätter" <me@ho.me> wrote in news:#ivghiX5DHA.1968
> @TK2MSFTNGP11.phx.gbl:
>
> > From: "G?nter Brandst"tter" <me@ho.me>
> > Subject: Re: Printout problem
> > Newsgroups: microsoft.public.word.vba.general
> >
> > 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
> >
> >
> >
> > --
> >
> >
>
> -------------------------------------------------------------------------
> > FIGHT BACK AGAINST SPAM!
> > Download Spam Inspector, the Award Winning Anti-Spam Filter
> > http://mail.giantcompany.com
> >
> >
> > "Peter Hewett" <Nospam@xtra.co.nz> a ,crit dans le message de
> > news:Xns947E679024859Iwlpth@207.46.248.16...
> >> 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?nter Brandst"tter" <me@ho.me> wrote in news:O8nEufQ5DHA.2576
> >> @TK2MSFTNGP11.phx.gbl:
> >>
> >> > 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
> >
>



Re: Printout problem by Peter

Peter
Wed Jan 28 15:13:10 CST 2004

Hi Gunter

Word uses section breaks so that you can distinguish each of the records in
the SourceData. Word can't use just simple page breaks as the MainDocument
may consist of more than 1 page.

Here's the code to print a particular section:

Sub PrintSection(ByVal docMailMerge As Word.Document, _
ByVal lngSection As Long)
Dim rngPrint As Word.Range

With docMailMerge.Sections

' Section specified must be valid
If lngSection <= .Count Then

' Unless we're printing the last section Exclude final
' character of section otherwise two sections will print
Set rngPrint = .Item(lngSection).Range
If lngSection < .Count Then rngPrint.MoveEnd wdCharacter, -1

' Have to select the range to print it!
rngPrint.Select
docMailMerge.PrintOut Range:=wdPrintSelection, _
Item:=wdPrintDocumentContent, PageType:=wdPrintAllPages, _
Background:=False
End If
End With
End Sub

When Word does a mail merge it adds a section break to the last record it
merges so you always get a blank section at the end of your document.

HTH + Cheers - Peter


"Günter Brandstätter" <me@ho.me> wrote in news:u3cOmwZ5DHA.1504
@TK2MSFTNGP12.phx.gbl:

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


Re: Printout problem by Günter

Günter
Thu Jan 29 02:41:27 CST 2004

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


--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


"Peter Hewett" <Nospam@xtra.co.nz> a écrit dans le message de
news:Xns947F67F68D899Iwlpth@207.46.248.16...
> Hi Gunter
>
> Word uses section breaks so that you can distinguish each of the records
in
> the SourceData. Word can't use just simple page breaks as the MainDocument
> may consist of more than 1 page.
>
> Here's the code to print a particular section:
>
> Sub PrintSection(ByVal docMailMerge As Word.Document, _
> ByVal lngSection As Long)
> Dim rngPrint As Word.Range
>
> With docMailMerge.Sections
>
> ' Section specified must be valid
> If lngSection <= .Count Then
>
> ' Unless we're printing the last section Exclude final
> ' character of section otherwise two sections will print
> Set rngPrint = .Item(lngSection).Range
> If lngSection < .Count Then rngPrint.MoveEnd wdCharacter, -1
>
> ' Have to select the range to print it!
> rngPrint.Select
> docMailMerge.PrintOut Range:=wdPrintSelection, _
> Item:=wdPrintDocumentContent, PageType:=wdPrintAllPages, _
> Background:=False
> End If
> End With
> End Sub
>
> When Word does a mail merge it adds a section break to the last record it
> merges so you always get a blank section at the end of your document.
>
> HTH + Cheers - Peter
>
>
> "Günter Brandstätter" <me@ho.me> wrote in news:u3cOmwZ5DHA.1504
> @TK2MSFTNGP12.phx.gbl:
>
> > 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
> >
> >
>