I have created two separate spreadsheets that serve two different purposes; however, I sometimes need to view information on one of them after looking at the other. Both files are worksheet protected.
I recorded the following macro to access the one from the other:
Workbooks.Open Filename:="DRIVE:\Path To File\Filename.xls"
Windows("Filename.xls").Activate
The problem I have with this is it assumes the file is not already open.
What do I add to the macro to counter the screen-pop I receive when the called file is already open?
Page 1 of 1
Macros linking Excel spreadsheets Opening an already open file?
#2
Posted 25 July 2005 - 11:36 PM
One way to check whether a workbook is already open is to check if it is in the list of workbooks
. You can't record such check. Find your macro and just add the code to do it for you.
For instance, try to set workbk=workbooks("filename"), and then if you can't create the workbk object, the object will be NOTHING, otherwise the file is already open. Read Help on the VBA side about the workbook object and the command SET.
Why do you need a macro? It seems to be complicating your life.
Perhaps you could setup a link, and then excel would open the "other" file for you. It normally works quite well, unless of course, you change the location or delete linked files or otherwise confuse yourself or excel. Read up in Excel Help about links to external workbooks.
For instance, try to set workbk=workbooks("filename"), and then if you can't create the workbk object, the object will be NOTHING, otherwise the file is already open. Read Help on the VBA side about the workbook object and the command SET.
Why do you need a macro? It seems to be complicating your life.
Perhaps you could setup a link, and then excel would open the "other" file for you. It normally works quite well, unless of course, you change the location or delete linked files or otherwise confuse yourself or excel. Read up in Excel Help about links to external workbooks.
Share this topic:
Page 1 of 1

Help


Back to top








