?
Solved

Disable Auto Macro In Excel Using VBA or Command Line Switches

Posted on 2008-06-09
5
Medium Priority
?
2,527 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

840 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