none
Print without Watermark RRS feed

  • Question

  • Hi,

    Is there a way to a code that can force the print event not to print a watermark?

    Thanks


    Thanks for everything, all your help is well appreciated
    Monday, June 13, 2011 3:48 PM

Answers

  • There are several ways to do this. I think this is the simplest.

    First, recognize that a watermark is just a Shape object anchored to a paragraph in the document header. If you go into the Options dialog and turn on display of anchors and paragraph marks, and then open the header pane and click the watermark to select it, you'll see its anchor in the left margin of the header paragraph.

    Make sure the anchor is in an otherwise empty paragraph (you can drag the anchor from one paragraph to another if necessary). Insert a bookmark to contain that empty paragraph mark, and name the bookmark "wm". (Any other name will do, but you'll have to adjust the macro below to match.)

    Then paste these macros into the document template:

    Sub FilePrint()
        ToggleWatermark
        Dialogs(wdDialogFilePrint).Show
        ToggleWatermark
    End Sub

    Sub FilePrintDefault()
        ToggleWatermark
        ActiveDocument.PrintOut Background:=False
        ToggleWatermark
    End Sub

    Private Sub ToggleWatermark()
        On Error Resume Next
        ActiveDocument.Bookmarks("wm").Range.Font.Hidden = _
          Not ActiveDocument.Bookmarks("wm").Range.Font.Hidden
    End Sub


    Jay Freedman
    MS Word MVP  FAQ: http://word.mvps.org
    • Marked as answer by scorpdevil Tuesday, June 14, 2011 12:25 PM
    Monday, June 13, 2011 9:10 PM

All replies

  • There are several ways to do this. I think this is the simplest.

    First, recognize that a watermark is just a Shape object anchored to a paragraph in the document header. If you go into the Options dialog and turn on display of anchors and paragraph marks, and then open the header pane and click the watermark to select it, you'll see its anchor in the left margin of the header paragraph.

    Make sure the anchor is in an otherwise empty paragraph (you can drag the anchor from one paragraph to another if necessary). Insert a bookmark to contain that empty paragraph mark, and name the bookmark "wm". (Any other name will do, but you'll have to adjust the macro below to match.)

    Then paste these macros into the document template:

    Sub FilePrint()
        ToggleWatermark
        Dialogs(wdDialogFilePrint).Show
        ToggleWatermark
    End Sub

    Sub FilePrintDefault()
        ToggleWatermark
        ActiveDocument.PrintOut Background:=False
        ToggleWatermark
    End Sub

    Private Sub ToggleWatermark()
        On Error Resume Next
        ActiveDocument.Bookmarks("wm").Range.Font.Hidden = _
          Not ActiveDocument.Bookmarks("wm").Range.Font.Hidden
    End Sub


    Jay Freedman
    MS Word MVP  FAQ: http://word.mvps.org
    • Marked as answer by scorpdevil Tuesday, June 14, 2011 12:25 PM
    Monday, June 13, 2011 9:10 PM
  • Just Perfect!!!

    Thanks a lot.


    Thanks for everything, all your help is well appreciated
    Tuesday, June 14, 2011 12:25 PM
  • HEy Jay Works perfect.

    But i have a doc with 2 pages which have 2 different backgrounds.... I made 2 bookmarks but i cant use the same name.

    wm

    How do i edit the marco to hide 2 bookmarks?

    thanks alot boyd

    Wednesday, January 2, 2013 3:30 AM
  • Do not know exactly why but this works fine!

    Public WithEvents appWord As Word.Application
    
    Private Sub Document_Open()
        Set appWord = Application
        ' Not sure if your image is a shape or inlineshape, so...
        If ThisDocument.Shapes.Count Then
            ' First Shape is now visible
            ThisDocument.Shapes(1).Visible = msoTrue
        ElseIf ThisDocument.InlineShapes.Count Then
            ' First inlineshpae has medium brightness
            ThisDocument.InlineShapes.Item(1).PictureFormat.Brightness = 0.5
        End If
    End Sub
    
    Private Sub appWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
     
     Dim intResponse As Integer
     
     intResponse = MsgBox("This document contains a background image. " & _
        "Would you like to hide it before printing?", vbYesNo, _
        "Hide Background Image?")
         If intResponse = vbYes Then
             hide_images
    
         ElseIf intResponse = vbNo Then
    
            show_images
         End If
    End Sub
    
    Sub hide_images()
    
        Application.DisplayStatusBar = True
        With ActiveWindow
            .DisplayHorizontalScrollBar = True
            .DisplayVerticalScrollBar = True
            .DisplayLeftScrollBar = False
            .StyleAreaWidth = CentimetersToPoints(0)
            .DisplayVerticalRuler = True
            .DisplayRightRuler = False
            .DisplayScreenTips = True
            With .View
                .ShowAnimation = True
                .Draft = False
                .WrapToWindow = False
                .ShowPicturePlaceHolders = False
                .ShowFieldCodes = False
                .ShowBookmarks = False
                .FieldShading = wdFieldShadingWhenSelected
                .ShowTabs = False
                .ShowSpaces = False
                .ShowParagraphs = False
                .ShowHyphens = False
                .ShowHiddenText = False
                .ShowAll = True
                .ShowDrawings = True
                .ShowObjectAnchors = False
                .ShowTextBoundaries = False
                .ShowHighlight = True
            End With
        End With
        With Options
            .UpdateFieldsAtPrint = False
            .UpdateLinksAtPrint = False
            .DefaultTray = "Druckereinstellungen verwenden"
            .PrintBackground = True
            .PrintProperties = False
            .PrintFieldCodes = False
            .PrintComments = False
            .PrintHiddenText = False
            .PrintDrawingObjects = False
            .PrintDraft = False
            .PrintReverse = False
            .MapPaperSize = True
        End With
        With ActiveDocument
            .PrintPostScriptOverText = False
            .PrintFormsData = False
        End With
    End Sub
    
    Sub show_images()
    
        With Options
            .UpdateFieldsAtPrint = False
            .UpdateLinksAtPrint = False
            .DefaultTray = "Druckereinstellungen verwenden"
            .PrintBackground = True
            .PrintProperties = False
            .PrintFieldCodes = False
            .PrintComments = False
            .PrintHiddenText = False
            .PrintDrawingObjects = True
            .PrintDraft = False
            .PrintReverse = False
            .MapPaperSize = True
        End With
        With ActiveDocument
            .PrintPostScriptOverText = False
            .PrintFormsData = False
        End With
    End Sub

    Thursday, January 17, 2013 11:22 PM