Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Sub Workbook_Open and BeforeClose not working

I have created the following macros in my workbook:
Sub Workbook_Open()
Application.CommandBars("Tools").Controls("Protect ion").Enabled = False
End Sub
Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Tools").Controls("Protect ion").Enabled = True
End Sub

Neither of these macros is working. When I open the file, the Tools
Protection is still enabled. If I run a separate macro to disable the
protection, then save the file and exit, the protection is still disabled.

I am running Excel 2003. The macros are in Module 1 of the worksheet project.

Any help would be very much appreciated!!!!

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 419
Default Sub Workbook_Open and BeforeClose not working

Dorothy,

I am running Excel 2003. The macros are in Module 1 of the worksheet
project.


You are trying to run code when workbook events occur. Regular/standar
modules will not detect workbook/worksheet events, so your code will not
work in a regular/standard module. You need to move it to the
"ThisWorkbook" module. If your Project Explorer has modules grouped
together in separate folders, then the "ThisWorkbook" module will be in the
"MS Excel Objects" folder.

HTH,

Conan




"Dorothy" wrote in message
...
I have created the following macros in my workbook:
Sub Workbook_Open()
Application.CommandBars("Tools").Controls("Protect ion").Enabled = False
End Sub
Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Tools").Controls("Protect ion").Enabled = True
End Sub

Neither of these macros is working. When I open the file, the Tools
Protection is still enabled. If I run a separate macro to disable the
protection, then save the file and exit, the protection is still disabled.

I am running Excel 2003. The macros are in Module 1 of the worksheet
project.

Any help would be very much appreciated!!!!

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sub Workbook_Open and BeforeClose not working

Thanks so much!! Problem solved!!

"Conan Kelly" wrote in message
...
Dorothy,

I am running Excel 2003. The macros are in Module 1 of the worksheet
project.


You are trying to run code when workbook events occur. Regular/standar
modules will not detect workbook/worksheet events, so your code will not
work in a regular/standard module. You need to move it to the
"ThisWorkbook" module. If your Project Explorer has modules grouped
together in separate folders, then the "ThisWorkbook" module will be in
the "MS Excel Objects" folder.

HTH,

Conan




"Dorothy" wrote in message
...
I have created the following macros in my workbook:
Sub Workbook_Open()
Application.CommandBars("Tools").Controls("Protect ion").Enabled = False
End Sub
Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Tools").Controls("Protect ion").Enabled = True
End Sub

Neither of these macros is working. When I open the file, the Tools
Protection is still enabled. If I run a separate macro to disable the
protection, then save the file and exit, the protection is still
disabled.

I am running Excel 2003. The macros are in Module 1 of the worksheet
project.

Any help would be very much appreciated!!!!

Thanks!




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
Workbook_Open not working? Geoff C Excel Programming 4 August 3rd 07 01:46 PM
Workbook_Open() Not working Dave Excel Programming 4 September 7th 06 02:41 AM
Workbook_Open not working Sheena N via OfficeKB.com Excel Discussion (Misc queries) 4 May 6th 05 01:31 AM
Workbook_Open and Workbook_BeforeClose not working Don[_19_] Excel Programming 0 August 10th 04 06:58 PM
Workbook_Open event not working jason Excel Programming 2 September 7th 03 04:02 PM


All times are GMT +1. The time now is 03:49 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"