Solved

Disable Auto Macro In Excel Using VBA or Command Line Switches

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

Technology Partners: 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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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 the scrolling table in Microsoft Excel using the INDEX function.

735 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