Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disabling workbook_open macro

Posted on 2013-10-22
4
Medium Priority
?
212 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

886 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