Solved

Disabling workbook_open macro

Posted on 2013-10-22
4
200 Views
Last Modified: 2013-11-12
I'm writing a macro that will open another workbook, grab some information and close the other workbook. I need to figure out how to disable the workbook_open macro in the workbook that is being opened. I've tried application.enableevents = false, then opening the workbook, then turning enableevents back on, but I keep getting a run time 1004 error. Does anyone know how to do this?
0
Comment
Question by:Mada123
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39592039
Application.EnableEvents = False

     'your code here

Application.EnableEvents = True

Open in new window

0
 

Accepted Solution

by:
Mada123 earned 0 total points
ID: 39592068
As I said before, tried exactly what thinkspacesolutions suggested.

application.enableevents = false

workbooks.open

application.enableevents = true

application.run macroname

The new workbook opens normally, and then generates a runtime error when using application.run. However, application.run works normally when application.enableevents isn't used.
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39592102
Sorry, I am working off my phone at the moment.  Let me clarify:

Try running your entire code before enabling events.  Does the runtime error still present?

application.enableevents = false

workbooks.open
application.run macroname

application.enableevents = true

Open in new window


One other thing to check is that you do not have a procedure with the same name as the module.

You may also look at:

Application.Run "'" & WBName & "'!Macro"

Open in new window

0
 

Author Closing Comment

by:Mada123
ID: 39641067
Answer is correct, but not solving my problem.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now