Solved

Disable Auto Macro In Excel Using VBA or Command Line Switches

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

773 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