• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Activate File instead of Open (if already open)

I have this simple ol' code of line running first when you select one of my macros;

Code:
 Workbooks.Open Filename:="~C:\Desktop\afilehasnoname.xlsm"

Problem is, if the file is already open - then it will either prompt to reopen the file (without saving changes) or end the sub if you ask it not to reopen the file.

Is there a way that if the file is already open then the code just changes to activate the file instead of opening it, my haphazard attempt didn't work

Code:
 Workbooks.Open Filename:="~C:\Desktop\afilehasnoname.xlsm"
On Error
   Windows("afilehasnoname.xlsm").Activate
 
Back
Top