activating excel from VB

  • Thread starter Thread starter mahesh
  • Start date Start date
M

mahesh

Hello there,

I'm running a VB program that call excel and manipulates workbooks and
I use the following code to get excel open from VB.

Dim xlapp As excel.Application
Set xlapp = CreateObject("excel.application")

However this always results in a new Excel instance and ignores any
already open instances of excel. I would like an existing instance to
be activated and if none exists, open a new one.

Is this possible?

Mahesh
 
Mahesh,

Try something like

Dim XLApp As Excel.Application
On Error Resume Next
Set XLApp = GetObject(, "Excel.Application")
If XLApp Is Nothing Then
Set XLApp = CreateObject("Excel.Application")
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top