473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Controlling how Excel starts when using VB.Net Automation

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
3 5040
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Niyazi | last post by:
Hi, I have to retrieve a data from AS400 DB2 and after working with data I have to export into one of existing Excel file. I can connect into specific library in AS400 DB2 using AS400...
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
3
by: Mansi | last post by:
I'm trying to use excel automation (from visual c# .NET) to fill data in a range by using arrays. I am using Microsoft's Knowledge Base Article 302096 as a reference and using the example listed...
12
by: D. Shane Fowlkes | last post by:
This most likely belongs in another forum but I thought I'd start here. I have a COM Object written in VB6. The DLL will access MS Excel and use it's Object Library to write a customized report...
12
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is...
3
by: Carlos Magalhaes | last post by:
Hey All, I am doing some excel automation using the excel COM. I can do most of the functions and its working well until I come across a formula. I can run a formula and insert the formula...
3
by: Mitchell Vincent | last post by:
Does anyone have some good examples of Excel automation with (VB).NET? I have some Excel spreadsheets that a customer needs parsed out but I've never tried to use Excel programatically before! ...
4
by: Hardy Wang | last post by:
Hi all, I have following code to read Excel content into a DataSet string connection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties=\"Excel...
0
by: SteelNetNob | last post by:
I am having a problem where I have a COM application that can be run stand-alone and programatically via COM interop. If an instance of the COM application is being run when my .NET application that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.