Solved

Disabling workbook_open macro

Posted on 2013-10-22
4
198 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
Comment Utility
Application.EnableEvents = False

     'your code here

Application.EnableEvents = True

Open in new window

0
 

Accepted Solution

by:
Mada123 earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Answer is correct, but not solving my problem.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

744 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

17 Experts available now in Live!

Get 1:1 Help Now