Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open() of locked project causing errors
I have a toolbar that runs macros from a locked project of an .xls
file that is always in a standard location. In this .xls file, under the ThisWorkbook page, one subroutine is: Private Sub Workbook_Open() If Not DEVELOPER Then Me.ChangeFileAccess Mode:=xlReadOnly EndIf EndSub This is to prevent people from editing the .xls file with the macros unless they set the DEVELOPER flag to true, which can only be done if you have the password to unlock the project. If this flag is set to false, as it is by default, as soon as you click a toolbar button, the workbook for the .xls file containing the macros will open in the background, run this routine and set itself to read-only. This worked fine with Excel 2000. However, when we switched over to Excel 2003, when you click the toolbar button and accept the security warnings, it says "Compile error in hidden module: ThisWorkbook". After more security warnings, it says it can't find the macro (I'm assuming this is only because of the former error). As soon as I unlock the project for viewing, everything works fine. Can anybody tell me how to fix this (other than the obvious setting the file as read-only rather than doing it in the code)? Thanks in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open() of locked project causing errors
Are there any MISSING references on XL2003? (VBE Tools - References) If so
they should be unchecked or corrected depending on what they are. Also, does the project compile without fail? Option Explicit must be at the top of every module including ThisWorkbook and the sheets if they have code, then VBE Debug - Compile <vba project. -- Tim Zych SF, CA "Craig" wrote in message ... I have a toolbar that runs macros from a locked project of an .xls file that is always in a standard location. In this .xls file, under the ThisWorkbook page, one subroutine is: Private Sub Workbook_Open() If Not DEVELOPER Then Me.ChangeFileAccess Mode:=xlReadOnly EndIf EndSub This is to prevent people from editing the .xls file with the macros unless they set the DEVELOPER flag to true, which can only be done if you have the password to unlock the project. If this flag is set to false, as it is by default, as soon as you click a toolbar button, the workbook for the .xls file containing the macros will open in the background, run this routine and set itself to read-only. This worked fine with Excel 2000. However, when we switched over to Excel 2003, when you click the toolbar button and accept the security warnings, it says "Compile error in hidden module: ThisWorkbook". After more security warnings, it says it can't find the macro (I'm assuming this is only because of the former error). As soon as I unlock the project for viewing, everything works fine. Can anybody tell me how to fix this (other than the obvious setting the file as read-only rather than doing it in the code)? Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Decimal rounding causing addition errors | Excel Discussion (Misc queries) | |||
conditional forming causing linking errors | Excel Worksheet Functions | |||
sumproduct causing memory errors? | Excel Worksheet Functions | |||
large sumproducts causing memory errors | Excel Discussion (Misc queries) | |||
Locked/Protect in Workbook_open not working in X2002 | Excel Programming |