BleepingComputer.com: Macros linking Excel spreadsheets

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Macros linking Excel spreadsheets Opening an already open file?

#1 User is offline   garnetwr 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 44
  • Joined: 10-December 04

  Posted 25 July 2005 - 10:32 PM

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?

#2 User is offline   tos226 

  • BleepIN--BleepOUT
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 1,423
  • Joined: 21-October 04
  • Gender:Female
  • Location:LocalHost

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 :thumbsup: . 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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users