ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   two same workbooks opened -- don't want this (https://www.excelbanter.com/excel-programming/434762-two-same-workbooks-opened-dont-want.html)

rchiuhk

two same workbooks opened -- don't want this
 
Dear all,

I have the excel file which is opened and run the dllfunction which will
manipulate this excel file.
How can I write in dllfunction so that it can work the excel file which has
been opened??

Let me mention more clearly.
xlapp=new excel.applicationclass() // Actually test.xls has been opened.
xlworkbook=xlapp.WorkBooks.open("test.xls",....); // open again, it will
make two test.xls excel screen. How to eliminate this and working on the
existing opened excel file??
.............................
I want as below.

if (There is instance of excel exists)
{
set xlApp to be excel instance
set xlWorkBook=xlApp.ActiveWorkBook;
}
else
{
create new excel instance and set to xlApp.
set xlWorkBook=xlApp.Workbooks.Open(...........)
}



joel

two same workbooks opened -- don't want this
 
I Usually use CreateObject and Getobject together and don't use Open.

Test if object exists. If it doesn't then use getobject to open the workbook.

"rchiuhk" wrote:

Dear all,

I have the excel file which is opened and run the dllfunction which will
manipulate this excel file.
How can I write in dllfunction so that it can work the excel file which has
been opened??

Let me mention more clearly.
xlapp=new excel.applicationclass() // Actually test.xls has been opened.
xlworkbook=xlapp.WorkBooks.open("test.xls",....); // open again, it will
make two test.xls excel screen. How to eliminate this and working on the
existing opened excel file??
.............................
I want as below.

if (There is instance of excel exists)
{
set xlApp to be excel instance
set xlWorkBook=xlApp.ActiveWorkBook;
}
else
{
create new excel instance and set to xlApp.
set xlWorkBook=xlApp.Workbooks.Open(...........)
}





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

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