![]() |
force users to enable macro so sheet cannot be printed
in access 2003 I have code that will stop users from printing the sheet.Now
that I have added a macro users can print if they do not enable the macro.Is there anyway to stop this happening? |
force users to enable macro so sheet cannot be printed
You need a contingency plan that renders the workbook useless if users do
not enable macros. Here is a sample................ Create a sheet named Dummy with a large message typed in the middle. "You have disabled Macros and this workbook is useless without them. Please close and re-open with macros enabled" Then add these two event codes to Thisworkbook module. Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim sht As Worksheet Application.ScreenUpdating = False Sheets("Dummy").Visible = xlSheetVisible For Each sht In ActiveWorkbook.Sheets If sht.Name < "Dummy" Then sht.Visible = xlSheetVeryHidden End If Next sht Application.ScreenUpdating = True ThisWorkbook.Save End Sub Private Sub Workbook_Open() Dim sht As Worksheet Application.ScreenUpdating = False For Each sht In ActiveWorkbook.Sheets If sht.Name < "Dummy" Then sht.Visible = True Sheets("Dummy").Visible = xlSheetVeryHidden End If Next sht Application.ScreenUpdating = True End Sub Gord Dibben MS Excel MVP On Wed, 10 Dec 2008 10:10:01 -0800, Zambian wrote: in access 2003 I have code that will stop users from printing the sheet.Now that I have added a macro users can print if they do not enable the macro.Is there anyway to stop this happening? |
force users to enable macro so sheet cannot be printed
Zambian-
You posted your question about access in an excel post. Are you working with Access or Excel? "Gord Dibben" wrote: You need a contingency plan that renders the workbook useless if users do not enable macros. Here is a sample................ Create a sheet named Dummy with a large message typed in the middle. "You have disabled Macros and this workbook is useless without them. Please close and re-open with macros enabled" Then add these two event codes to Thisworkbook module. Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim sht As Worksheet Application.ScreenUpdating = False Sheets("Dummy").Visible = xlSheetVisible For Each sht In ActiveWorkbook.Sheets If sht.Name < "Dummy" Then sht.Visible = xlSheetVeryHidden End If Next sht Application.ScreenUpdating = True ThisWorkbook.Save End Sub Private Sub Workbook_Open() Dim sht As Worksheet Application.ScreenUpdating = False For Each sht In ActiveWorkbook.Sheets If sht.Name < "Dummy" Then sht.Visible = True Sheets("Dummy").Visible = xlSheetVeryHidden End If Next sht Application.ScreenUpdating = True End Sub Gord Dibben MS Excel MVP On Wed, 10 Dec 2008 10:10:01 -0800, Zambian wrote: in access 2003 I have code that will stop users from printing the sheet.Now that I have added a macro users can print if they do not enable the macro.Is there anyway to stop this happening? |
force users to enable macro so sheet cannot be printed
Sorry . Working in excel 2003
"DStrong" wrote: Zambian- You posted your question about access in an excel post. Are you working with Access or Excel? "Gord Dibben" wrote: You need a contingency plan that renders the workbook useless if users do not enable macros. Here is a sample................ Create a sheet named Dummy with a large message typed in the middle. "You have disabled Macros and this workbook is useless without them. Please close and re-open with macros enabled" Then add these two event codes to Thisworkbook module. Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim sht As Worksheet Application.ScreenUpdating = False Sheets("Dummy").Visible = xlSheetVisible For Each sht In ActiveWorkbook.Sheets If sht.Name < "Dummy" Then sht.Visible = xlSheetVeryHidden End If Next sht Application.ScreenUpdating = True ThisWorkbook.Save End Sub Private Sub Workbook_Open() Dim sht As Worksheet Application.ScreenUpdating = False For Each sht In ActiveWorkbook.Sheets If sht.Name < "Dummy" Then sht.Visible = True Sheets("Dummy").Visible = xlSheetVeryHidden End If Next sht Application.ScreenUpdating = True End Sub Gord Dibben MS Excel MVP On Wed, 10 Dec 2008 10:10:01 -0800, Zambian wrote: in access 2003 I have code that will stop users from printing the sheet.Now that I have added a macro users can print if they do not enable the macro.Is there anyway to stop this happening? |
All times are GMT +1. The time now is 07:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com