Do not Print Header&Footer

A

acherony

HI.

I create Letter Template with some Macros.
Firts page header ist diferent from primary header. both include some
pictures.

my problem is I need to print the letter on blank paper or preprinted paper.

when I print on preprinted paper I do no want to print header&footer.

1,I try select the pictures from H&F then Selection.cut then print and
followed by
selection.paste.
was not working properly(to many problems)
2,I try to select just the content and then print selection.
ActiveDocument.content.select
but H&F will be selected as well.

I need help or ideas

thanks
 
K

Karl E. Peterson

acherony said:
I create Letter Template with some Macros.
Firts page header ist diferent from primary header. both include some
pictures.

my problem is I need to print the letter on blank paper or preprinted
paper.

when I print on preprinted paper I do no want to print header&footer.

Add a textbox within the header/footer to *contain* the elements that need
to be toggled on/off. Then, add code like this:

Public Sub GraphicsToggle()
Dim shp As Shape

With ActiveWindow
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
With .ActivePane.View
Select Case .Type
Case wdNormalView, wdOutlineView
.Type = wdPrintView
End Select
.SeekView = wdSeekCurrentPageHeader

For Each shp In Selection.HeaderFooter.Shapes
shp.Select
Selection.Font.Hidden = _
(Not Selection.Font.Hidden)
Next shp

.SeekView = wdSeekMainDocument
End With
End With
End Sub

Call it (from a toolbar button?) as needed.
 
D

Dave Lett

Hi,

You can probably use something as simple as the following:

Dim oSec As Section
Dim iHeadFoot As Integer
For Each oSec In ActiveDocument.Sections
For iHeadFoot = 1 To 3
oSec.Headers(iHeadFoot).Range.Font.Hidden = True
oSec.Footers(iHeadFoot).Range.Font.Hidden = True
Next iHeadFoot
Next oSec


HTH,
Dave
 
J

Jean-Guy Marcil

acherony was telling us:
acherony nous racontait que :
HI.

I create Letter Template with some Macros.
Firts page header ist diferent from primary header. both include some
pictures.

my problem is I need to print the letter on blank paper or preprinted
paper.

when I print on preprinted paper I do no want to print header&footer.

1,I try select the pictures from H&F then Selection.cut then print and
followed by
selection.paste.
was not working properly(to many problems)
2,I try to select just the content and then print selection.
ActiveDocument.content.select
but H&F will be selected as well.

Do you mean only for the first page?

If so, something like this:

'_______________________________________
Sub PrintNoHeaderFooter()

Dim rgeHeaderFooter As Range

ActiveDocument.Save

Set rgeHeaderFooter = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterFirstPage).Range
rgeHeaderFooter.Delete

Set rgeHeaderFooter = ActiveDocument.Sections(1) _
.Footers(wdHeaderFooterFirstPage).Range
rgeHeaderFooter.Delete

Dialogs(wdDialogFilePrint).Show

ActiveDocument.Undo 2

End Sub
'_______________________________________

But, if you have stuff in headers/footers that actually push stuff around on
the page, one you remove those headers/footers, the text might reflow in an
undesired way. In that case the only way I can think of is to add a white
rectangle on top of the stuff in the header/footer. It can get complicated.

Or, you can put the stuff in the first page header/footer in a text box
(without visible borders) and opt not to print "Drawing objects" (Print >
Options).
Of course this will not work if you have drawing objects in the page.
In such a case, try this code instead:

'_______________________________________
Sub PrintNoHeaderFooter()

Dim rgeHeaderFooter As Range

ActiveDocument.Save

Set rgeHeaderFooter = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterFirstPage).Range
rgeHeaderFooter.ShapeRange(1).Delete

Set rgeHeaderFooter = ActiveDocument.Sections(1) _
.Footers(wdHeaderFooterFirstPage).Range
rgeHeaderFooter.ShapeRange(1).Delete

Dialogs(wdDialogFilePrint).Show

ActiveDocument.Undo 2

End Sub
'_______________________________________


Finally, if you need to handle all headers/footers in the document, see:
http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm
Focus on Step 2.

Replace the code about replacing with something I suggest above.

In both example, I added
ActiveDocument.Save
in case Word crashes during the print out, in such case, the deleted
headers/footers might be gone for real.


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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