Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decimal rounding causing addition errors TKGerdie Excel Discussion (Misc queries) 2 April 16th 09 03:51 PM
conditional forming causing linking errors Dave Breitenbach Excel Worksheet Functions 0 April 1st 05 08:19 PM
sumproduct causing memory errors? dave Excel Worksheet Functions 1 March 3rd 05 09:31 AM
large sumproducts causing memory errors dave Excel Discussion (Misc queries) 0 March 2nd 05 09:06 PM
Locked/Protect in Workbook_open not working in X2002 Lydia[_2_] Excel Programming 1 July 15th 03 10:35 PM


All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"