|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Controlling how Excel starts when using VB.Net AutomationHi,
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 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. 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 -- Show quoteHide quoteTim 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. > > 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.
How to receive an array of doubles using VB from a C DLL
Question about rounding the decimal object = nothing? Need a numerical evaluator Compact .NET Framework on Desktop? What are the strings that define a connection's server version? Setting Null value in SQL update statement [Newbie] How can I do that ? Get Special Folder Decision trees |
|||||||||||||||||||||||