Microsoft Office Tutorials and References
In Depth Information
Restricting the User to a Portion of the Worksheet
' * * * * *¶
Sub StandardPrint()¶
'Standard print of the activesheet¶
End Sub¶
View the Appendix to learn how to store this procedure
in a ThisWorkbook module.
Option Explicit¶
' * * * * *¶
Private Sub Workbook_BeforePrint(Cancel As Boolean)¶
'Cancel the print if the macro didn't start it¶
If Not AllowPrint Then¶
Cancel = True¶
End If¶
End Sub¶
The code in the standard module requires the AllowPrint variable. The two
procedures are examples of how to use this technique. The rest of the code goes
in the ‘ThisWorkbook’ module.
The 'MyPrint' procedure, which is called from a button in a template or
workbook, must be customized to fit the user’s specific needs. The
'StandardPrint' procedure is not needed by the macro.
Restricting the User to a Portion of the Worksheet
Use this procedure to restrict the user to a specific area of a worksheet.
Example file:
Scenario: When using an important worksheet, protecting
the data may not be enough. You may need to restrict the
user from entering data or performing other tasks on the
Note: This worksheet does not need to be locked. The ScrollArea is not persistent—
meaning that when the workbook is closed and reopened, it is reset.
Therefore, make sure that this macro is called, at a minimum, when the
workbook is opened or when the worksheet is activated.
Search JabSto ::

Custom Search