ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   activating excel from VB (https://www.excelbanter.com/excel-programming/292048-activating-excel-vbulletin.html)

mahesh

activating excel from VB
 
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


---
Message posted from http://www.ExcelForum.com/


Chip Pearson

activating excel from VB
 
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

"mahesh " wrote in
message ...
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


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 09:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com