By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

Controlling how Excel starts when using VB.Net Automation

P: n/a
Hi,

I am currently creating an instance of Excel using VB.NET Automation.

dim xl as Excel.Application
xl = new Excel.Application

However, how can I have more control over the starting of Excel. For example
I want to specify command line switches, or prevent certain ComAdd-ins from
loading when I start Excel.

Regards
--
Tim Marsden
Oct 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Tim,

Based on my research, the Automation interface did not expose such method
about how to start Excel.

We have two approach to create an Excel instance with automation.
1. Just as you did, load the type and use New keyword
2. Use CreateObject method, which did not take other parameters e.g. start
switch.

Also if or not we load certain Com Addin is controlled by the registry
setting.
You may check the link below.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Excel \Addins
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Excel\ Addins

The difference between the two keys are whether or not it is installed for
all users, if yes, the key will be registered in HKEY_LOCAL_MACHINE key.

You may check the key value LoadBehavior of the addin under the key above,
you will find different value.
? 0 = Disconnect - Is not loaded.
? 1 = Connected - Is loaded.
? 2 = Bootload - Load on application Startup.
? 8 = DemandLoad - Load only when requested by user.
? 16 = ConnectFirstTime - Load only once (on next startup).

How to build an Office 2000 COM add-in in Visual Basic
http://support.microsoft.com/kb/238228

If you want to disable certain com addin, just use registry related code to
change the LoadBehavior registry value per KB 238228

So I think you may try to use Process.Start method to start a Excel.exe
process with argument.
Description of the startup switches for Excel
http://support.microsoft.com/kb/291288

You may have a try and let me know the result.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 24 '06 #2

P: n/a
Peter
Thanks for the reply, very must appreciated.

If I use the process.start method how do I then create a reference to the
Excel.Application object from the Process created using the Process.Start.

I need the reference so I can open workbooks, create worksheets, save etc.

Hope you can help

Regards
Tim

--
Tim Marsden
""Peter Huang" [MSFT]" wrote:
Hi Tim,

Based on my research, the Automation interface did not expose such method
about how to start Excel.

We have two approach to create an Excel instance with automation.
1. Just as you did, load the type and use New keyword
2. Use CreateObject method, which did not take other parameters e.g. start
switch.

Also if or not we load certain Com Addin is controlled by the registry
setting.
You may check the link below.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Excel \Addins
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Excel\ Addins

The difference between the two keys are whether or not it is installed for
all users, if yes, the key will be registered in HKEY_LOCAL_MACHINE key.

You may check the key value LoadBehavior of the addin under the key above,
you will find different value.
? 0 = Disconnect - Is not loaded.
? 1 = Connected - Is loaded.
? 2 = Bootload - Load on application Startup.
? 8 = DemandLoad - Load only when requested by user.
? 16 = ConnectFirstTime - Load only once (on next startup).

How to build an Office 2000 COM add-in in Visual Basic
http://support.microsoft.com/kb/238228

If you want to disable certain com addin, just use registry related code to
change the LoadBehavior registry value per KB 238228

So I think you may try to use Process.Start method to start a Excel.exe
process with argument.
Description of the startup switches for Excel
http://support.microsoft.com/kb/291288

You may have a try and let me know the result.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 24 '06 #3

P: n/a
Hi Tim,

To get an reference to an existing running office instance, you may use the
method below.
How to use Visual C# to automate a running instance of an Office program
http://support.microsoft.com/kb/316126

Also its a C# one, but the method is in the .NET FW, so it applied to
vb.net too.

If you have any concern, please feel free to let me know and I am glad to
be of help.

BTW: Please read Additional Notes in the KB link above when you are running
multple excel.exe in the system before running the KB code.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 25 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.