Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Phil,
The code I have placed below came from some kind soul posted on this UseNet. When the Workbook_Open procedure runs upon opening the file--we will call the child document--this code will look to see if the file name you supply is open--lets call it the parent document. If the parent document is open it will exit the Workbook_Open procedure. 1. Paste the line of code mentioned below in your Workbook_Open procedure located in the code for 'ThisWorkbook'; change the file name. 2. Next Paste the TestWorkbookOpen function below the end of the Workbook_Open procedure. Public Sub Workbook_Open() Application.ScreenUpdating = False '1. Place this line of code in your workbook_open procedure... If TestWorkbookOpen("TheParentFileName.xls") Then Exit Sub 'Your code here... Application.ScreenUpdating = True End Sub ' 2. Next Paste the TestWorkbookOpen function below the end of the Workbook_Open procedure. Function TestWorkbookOpen(WorkBookName As String) As Boolean ' returns TRUE if the workbook is open TestWorkbookOpen = False On Error GoTo WorkBookNotOpen If Len(Application.Workbooks(WorkBookName).Name) 0 Then TestWorkbookOpen = True Exit Function End If WorkBookNotOpen: End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Disable macros on a programmatically opening .xls file | Excel Discussion (Misc queries) | |||
Disable Macros when opening workbook | Excel Programming | |||
Turn Off Macros With Workbook Open | Excel Programming | |||
Open workbook-macros enabled, opening another with macros | Excel Programming | |||
Opening a workbook containing macros from VB | Excel Programming |