Hi,

There are two excel files i.e., Workbook1 and Workbook2.

There is an adodb connection in Workbook1.

What I'm trying to do is....opening Workbook2 from Workbook1 and running a macro in Workbook2

I'm able to do it till here.

Here is my problem:

In Workbook2, there are few sql queries which i need to run, i've declared an ADODB.connection, however i dont want to write any connection strings in Workbook2 and want to use the connection from Workbook1...

Please Login or Register  to view this content.
where a is declared as variant, con is declared as ADODB.Connection in Workbook2, roshan is a function in Workbook1 where the connection gets open using the ByRef parameter.

Can somebody help me out from this, thanks.

I debug the code, and found that "Roshan" function gets executed however as soon as the control returns from Workbook1 to Workbook2, the connection closes.