code for printing current section of a document

G

gils usenet acct

Hi All,

This discussion group has been like a good friend for years. I really
appreciate y'all. :)

I'd like code for printing the section the cursor is currently in.

How might I change the code below to accomplish this?

Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="s2",
PageType:=wdPrintAllPages _
, Collate:=True, Background:=False, PrintToFile:=False,
PrintZoomColumn:= _
0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

tia,

Gil

Gil Carter, MD, JD, FP, medical programming

http://www.TenSecondMedicalRecord.com, in use since 1990, free since 1997

http://www.KeyChainEMR.com Walk up to the medical ward computer, plug in,
do what you need, unplug and walk away.
 
J

Jay Freedman

Hi Gil,

The Selection.Information function can give you the current section
number, and you can use that to make a string to replace the "s2" in
your recorded macro. Also, you don't need all the default settings the
recorder insists on stuffing into the PrintOut statement. This will
do:

Dim PrintString As String
PrintString = "s" & _
Selection.Information(wdActiveEndSectionNumber)
ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, _
Pages:=PrintString, Background:=False

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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