How to access existing excel instance via COM

Hi everyone,

We use to code

Create Object COM-APPLIC of Class ‘Excel.Application’

to access Excel via COM. In the current project I need to access an excel spreadsheet that is already open.

In VBA this works just like this:

Option Explicit
Private Const xlText = -4158
Private Const xlCSV = 6

Dim xlsAnwendung   
dim i
on error resume next
Set xlsAnwendung = [b][color="darkred"]GetObject[/color][/b](,"Excel.Application")
if xlsAnwendung Is Nothing Then
  Set xlsAnwendung = [b][color="darkred"]CreateObject[/color][/b]("Excel.Application")
  xlsAnwendung.Visible = True
  With xlsAnwendung
            .Workbooks.Open "C:\Temp\Test.xls"
            .Sheets(1).Select
            .Sheets(1).Range("A33") = "Test erfolgreich"
            .Sheets(1).Range("B33") = xlsAnwendung
  end with
else    
  With xlsAnwendung
            .Sheets(1).Select
            .Sheets(1).Range("A33") = "Test erfolgreich"
            .Sheets(1).Range("B33") = xlsAnwendung
  end with
end if

In this VBA example CreateObject is just the equivalent to NATURALs Create Object. What I am looking for is the equivalent of the GetObject in the VBA example.

Is there a way to do this?

Even if I had to call an external routine I would be greatful if someone could tell me how to set the object “COM-APPLIC” to an existing excel instance if that would work.

Thanks for any help - it’s despreatly needed.