Microsoft Office Tutorials and References
In Depth Information
Forcing the Use of a Custom Print Procedure
Forcing the Use of a Custom Print Procedure
This procedure illustrates how to limit the use of the built-in Print (or Save)
commands, thus forcing the desired end result.
Example file:
Scenario: This macro could be used to create an invoice
when company policy dictates that each invoice must be
printed three times—perhaps one copy for the customer, with
proper formatting, and two copies for the company in black
ink only and without the logo and fancy formatting to save
on ink/toner. Making sure that the user prints it exactly right
each time can be a difficult task, so customizing the print
procedure is a lifesaver.
The sample file shows how to block the built-in commands from the File menu
and toolbars to force the use of a specific button, which does all the formatting
needed and takes care of the printing.
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
'Variable declaration¶
Public AllowPrint As Boolean
'Variable to check if the user pressed the right button¶
' * * * * *¶
Sub MyPrint()¶
'Turn the AllowPrint variable on¶
AllowPrint = True¶
'Printing code goes here¶
'Do all the stuff that is needed¶
With Range("A1")¶
.Font.Bold = True¶
.Interior.ColorIndex = 36¶
.Font.Size = 24¶
End With¶
'Do the custom print (2 copies, to the default printer)¶
ActiveSheet.PrintOut Copies:=2¶
'Turn off AllowPrint¶
AllowPrint = False¶
End Sub¶
Search JabSto ::

Custom Search