LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run macro in one open workbook only

Hi All,

I'm just a noob to VBA so i need some help which may be obvious.

I need to run a macro when save / saveas is used within WorkbookX. got
that part worked out,

but it tries to run in other workbooks that are also open, which I
don't want it to, because it is referring to sheets that only exist in
WorkbookX. Here's the code from WorkbookX

Sub Workbook_Open()

Application.CommandBars("Standard").Controls("&Sav e").OnAction =
"MySave"

Application.CommandBars("Worksheet Menu
Bar").Controls("File").Controls("Save").OnAction = "MySave"

Application.CommandBars("Worksheet Menu
Bar").Controls("File").Controls("Save As...").OnAction = "MySaveAs"

End Sub

Sub Workbook_BeforeClose(Cancel As Boolean)

Application.CommandBars("Standard").Controls("&Sav e").OnAction = ""

Application.CommandBars("Worksheet Menu
Bar").Controls("File").Controls("Save").OnAction = ""

Application.CommandBars("Worksheet Menu
Bar").Controls("File").Controls("Save As...").OnAction = ""

End Sub


So how do I limit this working to just WorkbookX - while still allowing
the user to change WorkbookX's name using SaveAs?

thanks

Paul

 
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
Macro in 2nd Open workbook Steve Excel Discussion (Misc queries) 1 January 28th 08 05:35 PM
run macro on workbook open kevin Excel Discussion (Misc queries) 3 March 4th 05 10:12 AM
how can I run a macro when I open a workbook? filo666 Excel Discussion (Misc queries) 2 March 2nd 05 07:56 PM
Macro to open another workbook missmelis01[_2_] Excel Programming 1 August 27th 04 08:37 PM
Open & run a workbook macro. Julian Milano[_2_] Excel Programming 7 January 29th 04 12:40 AM


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

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

About Us

"It's about Microsoft Excel"