Automating existing instance of Excel from c#

Microsoft OFFICE


  • 1. Opening files using VBS
    I found a thread regarding opening an MDE using some VBS code. My problem is that I'd like to open the file using Access Runtime. I can open the MDE using a shortcut I created "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" /runtime "actual file path" But, even though I can open it, no one else can because their security won't allow it. So here's the code I'm using: dim o set o=createobject ("Access.Application") o.automationsecurity=1 ' low. o.opencurrentdatabase "\\server\workgroup\filepath" o.visible=true o.usercontrol=true set o=nothing Is there a way to incorporate the runtime code into this?
  • 2. Problems with Outlook.Application class registry information.
    I have some applications that use the Outlook Object Model. For most customers, the applications work fine. However, for a few, the C++ statement "... CreateInstance("Outlook.Application");" fails. In some of these cases, the problem is caused by left over entries in the registry. It looks like this may occur if someone installs a new version of Outlook over an older version, and then later uninstalls (or maybe deletes) the newer version (but I have not verified the exact steps). By removing the left over entries from the registry, the problem with CreateInstance is corrected. Is there a Microsoft tool that will ensure that all registry information associated with Outlook is correct? Regards, Frank
  • 3. Outlook 2007 - POP fails after Exchange Disco/Reco
    This doesn't relate specifically to automation, but as it is an issue affecting my development, I decided to post here. I have an Outlook 2007 client set to connect to an Exchange mailbox and 3 POP mailboxes. The POP accounts deliver mail to the Exchange mailbox, not to .pst files. Every night a backup routine runs that shuts down Exchange for about 5 minutes. During that time, Outlook cannot connect of course. However, after Exchange comes back online, Outlook re-establishes a successful connection to Exchange automatically. After the reconnection though, none of the POP accounts function - all throw errors. If I manually close and reopen Outlook, the problem is resolved. Can you explain what is going on and what can be done to fix it? Thank you.

Automating existing instance of Excel from c#

Postby Giri » Tue, 16 Sep 2003 20:23:37 GMT

Any tips on how to "attach" to an existing running instance of Excel (2000)
from windows forms code written in C#  (bit like GetObject instead of


Re: Automating existing instance of Excel from c#

Postby Scott Glasgow » Wed, 17 Sep 2003 05:58:29 GMT


Will return the running instance of Excel. You might want to see if there
are any running instances first though using System.Diagnostics.Process


Re: Automating existing instance of Excel from c#

Postby Giri » Thu, 18 Sep 2003 02:05:45 GMT

Thanks for the info Scott !

It works although I when I reference to Excel my .NET objects seem to
appended with "class".  I have
Excel.ApplicationClass and not Excel.Application, or Excel.WorkbookClass and
not just Excel.WorkBook...

Anyone have any ideas why that may be ?


Re: Automating existing instance of Excel from c#

Postby v-phuang » Thu, 18 Sep 2003 12:04:12 GMT

Hi Giri,

The Excel.Application is an interface while Excel.ApplicationClass is 
implement Class. You may have a look at the Excel Object Browse.
You may do that by press Ctrl+Alt+J in the IDE.
You may take a look at the example in the link below.
302815 HOW TO: Handle Events for Excel by Using Visual C# .NET

Excel.Application exApp = 
Excel.Worksheet ws = 

Can you post some code about where you use the Excel.ApplicationClass?

Peter Huang 
Microsoft Online Partner Support 
Get Secure! 
This posting is provided "as is" with no warranties and confers no rights. 


Re: Automating existing instance of Excel from c#

Postby Giri » Fri, 19 Sep 2003 19:55:26 GMT

Thanks for the clarification.  It is working now.

Similar Threads:

1.Automating existing instances of word ?

Hi all

I'm trying to automate Word from another application

After creating the Application object, Documents Collection and Document 
object. These objects only seem to know about the stuff i've just created 
within that app ? ie if word was already open and had three docs open they 
don't seem to be in the documents collection ?

The app is not written in VB but a VB example would be good .... or am I 
doing something wrong ?



2.Get an object representing an existing Excel instance from Outlook

If i already have an Excel instance running, how to do I control that 
instance from Outlook?  I know that I can easily create a new instance 
from outlook and control that, but what i want to do is to create a new 
workbook in the existing instance and populate that workbook with data. 
  How do i do this?

ANy help would be most appreciated.

3.How to Show Existing IE Instance if Already Exists, Else Open One

Return to Microsoft OFFICE


Who is online

Users browsing this forum: No registered users and 77 guest