Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default macro only runs on fresh open of excel?

Hi Todd,

I see that you refer to "Worksheet MenuBar" and "Worksheet Menu Bar". Could
that be the problem?

--
Regards,

Jake Marx
MS MVP - Excel

Todd wrote:
I have a macro that only runs the first time you open
excel. If I close the workbook and reopen it , it does
not run (it is supposed to run everytime). I don't know
what to think about that. I went to different computer
station and it didn't run at all.


Help?


Todd

The error is marked at:

Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls(11)




Private Sub Workbook_Open()
ProtectionMenuBar_Add
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
ProtectionMenuBar_Delete
End Sub


Sub ProtectionMenuBar_Add()
Dim MenuItem As CommandBarControl
ProtectionMenuBar_Delete
Application.CommandBars("Worksheet
MenuBar").Controls.Add Type:= _
msoControlButton, ID:=893, Befo=11
If MenuItem Is Nothing Then Exit Sub
Set MenuItem = Nothing
End Sub

Sub ProtectionMenuBar_Delete()
Dim MenuItem As CommandBarControl
Set MenuItem = Application.CommandBars("Worksheet
Menu Bar").Controls(11)
If Not MenuItem Is Nothing Then
MenuItem.Delete
End If
Set MenuItem = Nothing
End Sub


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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Open Workbook created in Excel 2003 in a computer that runs Excel Artur Excel Discussion (Misc queries) 0 November 22nd 06 02:01 AM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Excel runs, but files will not open [email protected] Excel Discussion (Misc queries) 1 January 11th 05 08:30 PM
Called macro runs twice in excel 2002 Tom Ogilvy Excel Programming 1 September 10th 03 02:12 PM


All times are GMT +1. The time now is 02:29 PM.

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"