Solved

Disable Auto Macro In Excel Using VBA or Command Line Switches

Posted on 2008-06-09
5
2,482 Views
Last Modified: 2013-11-28
I need to launch Excel from an Access form control and open a spreadsheet that has an Auto_Open macro attached to it without running the macro.  I know I can do this by using the /safe command-line switch, but that throws up a "Macros Disabled" message that I don't want the users to be bothered with.

Is there another command-line switch that will disable this "macro warning" message when running in Safe Mode?  If not, how can I do this with VBA?
0
Comment
Question by:lwillis32
  • 2
  • 2
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 21748858
How are you doing this?

If you use automation to open an excel workbook the auto-open macro does not run.

0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 21749402
If your macro is running when automated then it's not an Auto_Open macro (as Peter57r explained), it must be a Workbook_Open macro. If you want to prevent that, use:
Application.Enableevents = False
' code to open workbook
Application.Enableevents = True

Do not forget to re-enable events with that last line!

Regards,
Rory
0
 

Author Comment

by:lwillis32
ID: 21753832
The spreadsheet has an Auto_Open macro.  This is the one I want to disable.

I am opening the spreadsheet with the following command from an access control:

Shell "excel.exe /safe t:\dailytimesheet1.xls", vbNormalFocus

Lisa
   
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 21753948
You can use:

Dim objExcel as Object
Dim objWB as Object
Set objExcel = Createobject("Excel.Application")
Set objWB = objExcel.Workbooks.Open("t:\dailytimesheet1.xls")
objExcel.Visible = True

Regards,
Rory
0
 

Author Closing Comment

by:lwillis32
ID: 31465622
Thanks for the help
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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

790 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