Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

In Excel 2007 how to switch off macro with a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Micky - 24 Sep 2007 21:44 GMT
Spreadsheet "A" runs a macro that opens spreadsheet "B". It gets data and
then closes "B" without saving (other spread sheets access "B" and deposit
data). A, then uses data for report.

However, when "B" opens it runs its own macros (the code doesn't ask it to
do this) and this creates a mess.
Otto Moehrbach - 24 Sep 2007 21:53 GMT
Micky
   Apparently, Workbook B has code that runs automatically when that file
is opened.  What you have to do is either change that code so that it does
you no harm or delete it.  Post back if you need more.  HTH  Otto
> Spreadsheet "A" runs a macro that opens spreadsheet "B". It gets data and
> then closes "B" without saving (other spread sheets access "B" and deposit
> data). A, then uses data for report.
>
> However, when "B" opens it runs its own macros (the code doesn't ask it to
> do this) and this creates a mess.
Greg Lovern - 24 Sep 2007 23:17 GMT
If B's macros are being run from B's Workbook_Open event, then use
Application.EnableEvents:

Dim bEnableEvents as Boolean
bEnableEvents = Application.EnableEvents
Application.EnableEvents = False
'<open B here>
Application.EnableEvents = bEnableEvents

But that won't help if B's macros are being run from an auto_open
macro. In that case, since you're only reading data, you could leave B
closed and read the data from A either with formulas or with an ODBC
query.

Another option if you're in charge of the other workbooks' macros:
>From the macros in the other workbooks that write to B, or in B's
Workbook_BeforeClose event, save out text files with the data. Then
open those text files in A instead of opening B.

Greg Lovern
http://PrecisionCalc.com

> Spreadsheet "A" runs a macro that opens spreadsheet "B". It gets data and
> then closes "B" without saving (other spread sheets access "B" and deposit
> data). A, then uses data for report.
>
> However, when "B" opens it runs its own macros (the code doesn't ask it to
> do this) and this creates a mess.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.