Lene Fredborg, DocTools, har hvert år siden 2008 modtaget den prestigefyldte pris som Microsoft Most Valuable Professional (MVP) i Word – link til information om MVP Award'en DocTools - dokumentautomatisering - add-ins, makroer og skabeloner til Microsoft Word (logo) Dokumentautomatisering
Add-ins & Makroer
Til Microsoft Word
Dokumentautomatisering, skabeloner (templates), add-ins og makroer til Microsoft Word (grafik)

Bogmærk denne side | Tip en ven om DocTools

Søg thedoctools.com:

Custom Search


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


    '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...

BulletADD-INS Word add-ins ready for use - work smarter in Word

Copyright © 2006-2018 Lene Fredborg – DocTools ApS – alle rettigheder forbeholdt | Microsoft Word skabeloner (templates) – add-ins – VBA makroer | Spar tid og arbejd mere effektivt i Microsoft Word
Privat politik | Betingelser for brug | Om cookies | Bogmærk denne side | Tip en ven | Links | Kontakt