Solved

Disabling workbook_open macro

Posted on 2013-10-22
4
204 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

830 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