Solved

Disabling workbook_open macro

Posted on 2013-10-22
4
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

738 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