Microsoft has awarded Lene Fredborg, DocTools, the Microsoft MVP award for Word each year since 2008. Link to info about the MVP Award at Microsoft.com DocTools - document automation - add-ins, macros and document templates for Microsoft Word (logo) Document Automation
Add-ins & Macros
Document Templates
For Microsoft Word
Document automation, templates, add-ins, macros, for Microsoft Word (graphic)



Bookmark this page | Tip a friend about DocTools


Search thedoctools.com:

Custom Search



Macros...

Macro – Print Without Margins Warning

Most printers cannot print to the edge of the paper. If you attempt to print a document with content that is outside the printable area of the page, a warning will tell you that there is a problem. You can choose to ignore the problem or you can cancel the print operation in order to fix the problem. There may be times when you want to suppress the warning and print the entire document despite of the margins problem. This article provides a couple of macros you can use for that purpose.

Terms of use

You are welcome to use the macros and Word tips provided on this website. The contents is copyright. You may not reproduce any of contents (with or without modification or credits) elsewhere on the web, or on CD. Please link to the contents on this website instead.

Please note that all free Word tips, macros, add-ins and demos are provided "as is" and without obligation. See also detailed Terms of use.


The illustration below shows the warning that appears if you attempt to print a document with too narrow margins for your printer:

Warning telling the margins exceeds the printers limitations

Note the message refers to "section 1" in this case. Since margins are properties of sections, the warning may appear several times if you attempt to print a document with several sections. This could, for example, be the case in relation to documents created via mail merge.

Two different macro versions are included below. Both macro versions suppress the margins warning. If you add one of the macros to your Normal.dot / Normal.dotm template, you can use that macro for printing your special documents. You could assign a keyboard shortcut to the macro or assign the macro to a toolbar button in order to make it easy to print your documents.

Macro 1 – no margins warning – no Print dialog

The macro below will suppress the margins warning and print the active document without showing the Print dialog box:


Sub Print_ShowNoMarginsWarning_DoNotShowPrintDialog()
    With Application
        'Turn off DisplayAlerts
        .DisplayAlerts = wdAlertsNone

        'Print document
        'Background print must be turned off to prevent message
        .PrintOut Background:=False

        'Turn on DisplayAlerts again
        .DisplayAlerts = wdAlertsAll
    End With
End Sub

Macro 2 – no margins warning – show Print dialog

The macro below will also suppress the margins warning but as opposed to the macro above, the Print dialog box will be shown, letting you specify the desired print settings:


Sub Print_ShowNoMarginsWarning_ShowPrintDialog()
    Dim bPrintBackgroud As Boolean

    'Save current setting of background printing
    bPrintBackgroud = Options.PrintBackground
    Options.PrintBackground = False

    'Turn off DisplayAlerts
    Application.DisplayAlerts = wdAlertsNone

    Dialogs(wdDialogFilePrint).Show

    'Turn on DisplayAlerts again
    Application.DisplayAlerts = wdAlertsAll

    'Set original background printing setting
    Options.PrintBackground = bPrintBackgroud
End Sub

About Application.DisplayAlerts

Note that the code line "Application.DisplayAlerts = wdAlertsNone" suppresses not only the margins settings warning but all other types of warnings too. Since Word does not automatically set DisplayAlerts back, the last line is used to set DisplayAlerts back to show all alerts again.


Related information

See general information about VBA macros and code snippets, incl. information about how to install macros.



Top of page

Back to Macros...




Copyright © 2006-2017 Lene Fredborg – DocTools ApS – all rights reserved | Microsoft Word Templates – add-ins – VBA macros | Save time and work more efficiently in Microsoft Word
Privacy policy | Terms of use | Cookies policy | Bookmark this page | Tip a friend | Links | Contact