Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to get "/automation" when automating?

According to MS, the /automation switch for Excel disables all
automatically opened files and auto-run macros. You get this feature
when starting Excel like "excel.exe /automation". But, I am starting
Excel from a C# program, not a command line, and I am having issues
with auto-run macros. How can I disable the auto-run macros when
actually automating Excel? A snippet of my code is below.

Thanks,
Mike

*************

MSExcel.Application app = new MSExcel.Application();
try
{
app.Workbooks.Open(filePath, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value);
...
}

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default How to get "/automation" when automating?

You can use a switch option on the command line such as

excel /safe

More options are shown on the microsoft web page

http://office.microsoft.com/en-us/ex...580301033.aspx

" wrote:

According to MS, the /automation switch for Excel disables all
automatically opened files and auto-run macros. You get this feature
when starting Excel like "excel.exe /automation". But, I am starting
Excel from a C# program, not a command line, and I am having issues
with auto-run macros. How can I disable the auto-run macros when
actually automating Excel? A snippet of my code is below.

Thanks,
Mike

*************

MSExcel.Application app = new MSExcel.Application();
try
{
app.Workbooks.Open(filePath, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value);
...
}


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default How to get "/automation" when automating?

When you start Excel via automation, which I believe you're doing, the
/automation switch is automatically applied (thus the name).

For unbelievers put this in a VBS file and run it:

Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "c:\Book1.xls", 3
XL.Visible = True

Note that no add-ins, Personal.xls, etc. are opened.

and I am having issues with auto-run macros.


If you're opening a workbook subsequently of course its events will run.
Maybe you should expand on the issues you're having.

--
Jim
wrote in message
oups.com...
| According to MS, the /automation switch for Excel disables all
| automatically opened files and auto-run macros. You get this feature
| when starting Excel like "excel.exe /automation". But, I am starting
| Excel from a C# program, not a command line, and I am having issues
| with auto-run macros. How can I disable the auto-run macros when
| actually automating Excel? A snippet of my code is below.
|
| Thanks,
| Mike
|
| *************
|
| MSExcel.Application app = new MSExcel.Application();
| try
| {
| app.Workbooks.Open(filePath, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value, Missing.Value, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value, Missing.Value, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value);
| ...
| }
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to get "/automation" when automating?

The specific auto-run macro that I know of with potential to cause
trouble at this point is "Workbook_Open()". I have been tasked with
writing a server based program to update a bunch of user's
spreadsheets. I wondered what would happen if users made
Workbook_Open macros when my code opened those spreadsheets. Well,
they get run. So, my issue is the potential for trouble of running
unknown code. Is there something I can do?

Thanks,
Mike

On Mar 8, 4:03 am, "Jim Rech" wrote:
When you start Excel via automation, which I believe you're doing, the
/automation switch is automatically applied (thus the name).

For unbelievers put this in a VBS file and run it:

Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "c:\Book1.xls", 3
XL.Visible = True

Note that no add-ins, Personal.xls, etc. are opened.

and I am having issues with auto-run macros.


If you're opening a workbook subsequently of course its events will run.
Maybe you should expand on the issues you're having.

--
wrote in message

oups.com...
| According to MS, the /automation switch for Excel disables all
| automatically opened files and auto-run macros. You get this feature
| when starting Excel like "excel.exe /automation". But, I am starting
| Excel from a C# program, not a command line, and I am having issues
| with auto-run macros. How can I disable the auto-run macros when
| actually automating Excel? A snippet of my code is below.
|
| Thanks,
| Mike
|
| *************
|
| MSExcel.Application app = new MSExcel.Application();
| try
| {
| app.Workbooks.Open(filePath, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value, Missing.Value, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value, Missing.Value, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value);
| ...
| }
|



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to get "/automation" when automating?

Mike,
Application.EnableEvents=False

Of course, you will need to set to True after opening if any of your own
code depends on Excel events.

NickHK

wrote in message
oups.com...
The specific auto-run macro that I know of with potential to cause
trouble at this point is "Workbook_Open()". I have been tasked with
writing a server based program to update a bunch of user's
spreadsheets. I wondered what would happen if users made
Workbook_Open macros when my code opened those spreadsheets. Well,
they get run. So, my issue is the potential for trouble of running
unknown code. Is there something I can do?

Thanks,
Mike

On Mar 8, 4:03 am, "Jim Rech" wrote:
When you start Excel via automation, which I believe you're doing, the
/automation switch is automatically applied (thus the name).

For unbelievers put this in a VBS file and run it:

Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "c:\Book1.xls", 3
XL.Visible = True

Note that no add-ins, Personal.xls, etc. are opened.

and I am having issues with auto-run macros.


If you're opening a workbook subsequently of course its events will run.
Maybe you should expand on the issues you're having.

--
wrote in message

oups.com...
| According to MS, the /automation switch for Excel disables all
| automatically opened files and auto-run macros. You get this feature
| when starting Excel like "excel.exe /automation". But, I am starting
| Excel from a C# program, not a command line, and I am having issues
| with auto-run macros. How can I disable the auto-run macros when
| actually automating Excel? A snippet of my code is below.
|
| Thanks,
| Mike
|
| *************
|
| MSExcel.Application app = new MSExcel.Application();
| try
| {
| app.Workbooks.Open(filePath, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value, Missing.Value, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value, Missing.Value, Missing.Value, Missing.Value,
| Missing.Value,
| Missing.Value);
| ...
| }
|





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Understanding: "BUG: VB Hangs While Automating Excel Using OLE Control" Don Wiss Excel Programming 1 May 5th 06 03:28 AM
Macro crashes "Automation error" during copy of workbook with char Yorch Excel Programming 0 January 30th 06 09:09 PM
Automating the "Oval" Object Phil Hageman[_3_] Excel Programming 5 April 15th 04 02:34 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"