Solved

How to print a Word 2010 document omitting pictures in header and footer

Posted on 2011-09-13
4
375 Views
Last Modified: 2013-11-05
I have a word document with a .png picture in the header and in the footer (essentially -- letterhead).  I want to create a macro to print this document regularly without the header and footer pictures (in other words print the "letter" without the "letterhead").  Manually -- I can select the picture in the header and in the footer and turn brightness up to 100% - then print - then reset the two pictures BUT how can I do this programatically .. ??  I tried to simply record a macro for this but when recording I was unable to simply click oh the picture in order to affect it.

Hopefully I am being clear.  Please advise.  Relatively urgent .. :-(
0
Comment
Question by:paulflint
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Scottyworld earned 500 total points
ID: 36533975
Save the following code as a macro.
It essentially formats the header and footer as hidden, then reverts it back afterwards
 
Sub PrintDocWithoutHeaderFooter()
Dim s As Section
For Each s In ActiveDocument.Sections
s.Headers(wdHeaderFooterEvenPages).Range.Font.Hidden = True
s.Headers(wdHeaderFooterFirstPage).Range.Font.Hidden = True
s.Headers(wdHeaderFooterPrimary).Range.Font.Hidden = True

s.Footers(wdHeaderFooterEvenPages).Range.Font.Hidden = True
s.Footers(wdHeaderFooterFirstPage).Range.Font.Hidden = True
s.Footers(wdHeaderFooterPrimary).Range.Font.Hidden = True
Next s

Options.PrintHiddenText = False

Dialogs(wdDialogFilePrint).Show

For Each s In ActiveDocument.Sections
s.Headers(wdHeaderFooterEvenPages).Range.Font.Hidden = False
s.Headers(wdHeaderFooterFirstPage).Range.Font.Hidden = False
s.Headers(wdHeaderFooterPrimary).Range.Font.Hidden = False

s.Footers(wdHeaderFooterEvenPages).Range.Font.Hidden = False
s.Footers(wdHeaderFooterFirstPage).Range.Font.Hidden = False
s.Footers(wdHeaderFooterPrimary).Range.Font.Hidden = False

Next s

End Sub

Open in new window

0
 

Author Comment

by:paulflint
ID: 36535124
Very good - the only caveat is that the header also contains two lines of text that I don't want to hide!!  Being the person's name and direct phone line (don't forget this is "letterhead" ) - I just  want to hide the .png picture in the header and footer (the pictures are the firm logo, address, etc. in colour).  What I would like ideally is something that hides just the pictures or even better something that just turns brightness of the picture .png to 100% brightness so it still keeps the space - prints - then "resets" the picture.  I tried to create this by recording these steps but I can't seem to select the picture in recording mode .. :-(.  Any further assistance would be really appreciated !!
0
 
LVL 9

Expert Comment

by:Scottyworld
ID: 36540316
I think the problem you'll face here is that in Word you cannot name/label the image, and therefore cannot select it individually to alter its properties.

The below option would prevent the printing of all images:

In the header, create a text box. Now insert your picture into the text box. This brings your image into the drawing layer of Word.

Now create and run the following macro
Sub Macro3()

    Options.PrintDrawingObjects = False
    
    Dialogs(wdDialogFilePrint).Show
    
    Options.PrintDrawingObjects = True

End Sub

Open in new window


This will stop all drawings from printing, give you the option to print, then reset the option afterwards
0
 

Author Closing Comment

by:paulflint
ID: 36557140
Modified slightly but this was great, thanks.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now