ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get reference to a file opened in another instance of XL (https://www.excelbanter.com/excel-programming/414606-get-reference-file-opened-another-instance-xl.html)

XP

Get reference to a file opened in another instance of XL
 
Using Office 2003;

Generic:
I need to loop thru all open MS-Excel files in another instance of XL with
the object in mind of getting a reference to a particular file opened as a
template. I can positively identify the template file by the contents of
certain cells in the template.

Specific:
The user will be opening an Oracle Financials, Fixed Asset (CPR) ADI
spreadsheet which always opens in a new instance of XL. I need to get a
reference to this spreadsheet and populate it with data from an array.

I can do all of this just fine, but it's the reference to the other instance
that is a challenge. Any help would be appreciated.



Gary Brown[_4_]

Get reference to a file opened in another instance of XL
 
Assuming that both instances of Excel use your Windows Registry, how about...
in the 1st instance of excel, put the filename you want the 2nd instance to
know about into the registry and then
in the 2nd instance of excel, take the filename out of the registry and open
the file or whatever?

Excel puts the information into...
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\


Examples:

'put data in registry in a macro in 1st instance
SaveSetting APPNAME:="MyFileName", _
section:="FileName", Key:="Value", _
setting:=ActiveWorkbook.FullName
- - - - - - - - -

'get data out of registry using a macro in 2nd instance
strMyFileName = GetSetting(APPNAME:="MyFileName", _
section:="FileName", Key:="Value")

'open the file in the 2nd instance
Workbooks.Open Filename:=strMyFileName
--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"XP" wrote:

Using Office 2003;

Generic:
I need to loop thru all open MS-Excel files in another instance of XL with
the object in mind of getting a reference to a particular file opened as a
template. I can positively identify the template file by the contents of
certain cells in the template.

Specific:
The user will be opening an Oracle Financials, Fixed Asset (CPR) ADI
spreadsheet which always opens in a new instance of XL. I need to get a
reference to this spreadsheet and populate it with data from an array.

I can do all of this just fine, but it's the reference to the other instance
that is a challenge. Any help would be appreciated.




All times are GMT +1. The time now is 08:35 AM.

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