automating customized printing

T

TripleT

Hi

I've previously posted this question on the "printing" board. As yet
haven't had a response, and after thinking about it I thought that
actually might be VBA. Can anyone help me on this?

I'm trying to set up a document that gives an option to prin
everything excluding the last page. Now the last page number may chang
depending on how much info is filled out inside the document.

Is there an easy way to do this?

Of course they'll still be able to use the print button to print th
whole thing if they like.

Cheers, Triple
 
D

Doug Robbins - Word MVP

Use the following code:

Dim i As Integer
i = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) - 1
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="1", To:="i"


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
T

TripleT

Hi Doug

Thanks so much for that. I tried to run it, and it didn't work for me
After looking at the document a little more closely, I realised that
had sections in the document. Could this be messing things up?

So, I guess I need to modify the code so that it looks at the number o
sections, prints all the pages except the last page of the las
section.

Is this possible? Would you please help.

Many thanks,
Triple
 
D

Doug Robbins - Word MVP

The presence of Section would cause that to fail. Try this instead:

Dim myrange As Range
Selection.EndKey wdStory
Set myrange = ActiveDocument.Bookmarks("\page").Range
myrange.End = myrange.Start - 1
myrange.Start = ActiveDocument.Range.Start
myrange.Select
ActiveDocument.PrintOut Range:=wdPrintSelection


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
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