|   |  | 
 | 
 
 | 
		|  | 
    
		| 
				
				
			 | 
	
	
		| 
				Word
			 | 
				Remove Header Images Before Print
			 | 
				 | 
	
		| 
				Ease of Use
			 | 
				Easy
			 | 
	
		| 
				Version tested with
			 | 
				2002 
			 | 
	
		| 
				Submitted by:
			 | 
				Jacob Hilderbrand
			 | 
		
		| 
				Description:
		 | 
					This macro offers the user the option of printing headers. It is set up to work for only a specified template. 
			 | 
	
		| 
				Discussion:
			 | 
				You have a template that has an image on the Header. For only documents based on this template, you want the user to be prompted with a message before they print. The message asks whether they want to print the header or not. You want it to run for any document that is created from a specific template. This is ideal for people who want to see the logo in their documents, but are printing onto pre-printed stationery. 
			 | 
	
	
		| 
				Code:
			 | 
				 
					instructions for use
				
			 | 
	
		| 
			 
 
Option Explicit 
 
Dim oAppClass As New ThisApplication 
 
Private Sub Document_New() 
     
    Set oAppClass.oApp = Word.Application 
     
End Sub 
 
 
 
 
Option Explicit 
 
Public WithEvents oApp As Word.Application 
 
Private Sub oApp_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean) 
     
    Dim MyTemplate      As String 
    Dim Remove          As VbMsgBoxResult 
     
    Application.ScreenUpdating = False 
     
    Cancel = True 
    MyTemplate = ActiveDocument.AttachedTemplate.Name 
    If MyTemplate = "Doc1.dot" Then 
        Remove = MsgBox("Do you want to print the logos?", vbQuestion + vbYesNo) 
        If Remove = vbNo Then 
            If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ 
            ActivePane.View.Type = wdOutlineView Then 
                ActiveWindow.ActivePane.View.Type = wdPrintView 
            End If 
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 
            Selection.Find.ClearFormatting 
            With Selection.Find 
                .Text = "^g" 
            End With 
            Selection.Find.Execute 
            Selection.Copy 
            Selection.Delete Unit:=wdCharacter, Count:=1 
            ActiveDocument.PrintOut 
            DoEvents 
            Selection.Paste 
            Application.CommandBars("Header and Footer").Visible = False 
            DoEvents 
        Else 
            ActiveDocument.PrintOut 
        End If 
    End If 
     
    Application.ScreenUpdating = True 
     
End Sub 
 | 
	
		| 
			
				How to use:
			 | 
				 Open Word.
Press Alt + F11 to open VBE.
Double Click ThisDocument from the Project Explorer.
Paste the code from above that goes into ThisDocument.
Select Insert Class Module.
Rename the Class Module to ThisApplication from the Properties Window.
Paste the code from above that goes in the Class Module.
Close VBE (Press Alt + Q or press the X in the top right hand corner).
Add a header to the Document.
Save the Document as Doc1.dot (A Template, If you rename it you must change the name in the code).
Close the Document.
Create a New Document from the Doc1.dot template.
Print.
Select Yes to print the image, No to not print the image.
 | 
	
		| 
				Test the code:
			 | 
				 Refer to the "How To Use" section.
Download the attachment for an working example.
 | 
	
		| 
				Sample File:
			 | 
					PrintModification.zip 15.51KB 
			 | 
    
		| 
				Approved by mdmackillop
			 | 
    
		| 
				
			 
			
 
This entry has been viewed 142 times.
 | 
    
		| 
				
				
			 |