Try this in the ThisDocument code module,
Option Explicit
Private WithEvents m_App As Application
Private m_IsPrinting As Boolean
Private Sub CommandButton1_Click()
MsgBox "Show Userform"
End Sub
Private Sub Document_Open()
Set m_App = Application
End Sub
Private Sub m_App_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
If Not m_IsPrinting Then
If StrComp(Doc.FullName, ThisDocument.FullName, vbTextCompare) = 0 Then
m_IsPrinting = True
With ThisDocument
.Shapes(1).Visible = False
.PrintOut Background:=False
.Shapes(1).Visible = True
End With
m_IsPrinting = False
Cancel = True
End If
End If
End Sub
Bookmarks