Solved

Disable Auto Macro In Excel Using VBA or Command Line Switches

Posted on 2008-06-09
5
2,475 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

705 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

19 Experts available now in Live!

Get 1:1 Help Now