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