VB and VBA Users Source Code: Force windows to open new Excel
[
Home
|
Contents
|
Search
|
Reply
| Previous |
Next
]
VB/VBA Source Code
Force windows to open new Excel
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, July 10, 2000
Hits:
936
Category:
Unspecified
Article:
If you don't want any workbooks double clicked in explorer to open in your current copy of Excel, then paste the following code into a module in your Excel Workbook: Option Explicit Sub Auto_Open() 'Set the name of the procedure to run when a new window is activated. Application.OnWindow = "CloseNew" Application.DisplayAlerts = False 'Force a New Excel to Open when double clicking a File from Explorer Application.IgnoreRemoteRequests = True Application.DisplayAlerts = True End Sub Sub Auto_Close() 'Restore settings Application.OnWindow = "" Application.IgnoreRemoteRequests = False End Sub Sub CloseNew() '---This code is run everytime the application window changes. If ActiveWorkbook.Name <> ThisWorkbook.Name Then ActiveWorkbook.Close False MsgBox "This is a Private copy of Excel! ", vbExclamation End If End Sub Note, you do not need to manually call these routines as Excel will automatically run them during the opening and activation of the workbook.
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder