Solved

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

Posted on 2011-09-13
4
380 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
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.

810 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