Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've written code to open a workbook and set path and file name variables
based on values in named ranges of the open workbook. I then use these variables to open three additional workbooks and minimize them. All that is working fine. However, I need to close the three minimized workbooks when I close the main workbook, I presume in the BeforeClose event. I can't seem to figure out how to do this. I tried setting public variables for the 3 workbooks, but that's not working either. I'm a novice, obviously. Can anyone supply the code to accomplish this task? Here's the code I've written to open the 3 supporting workbooks: Public Wbk1 As Workbook Public Wbk2 As Workbook Public Wbk3 As Workbook Private Sub Workbook_Open() Application.ScreenUpdating = False Dim Pname1 As String, Pname2 As String, Pname3 As String Dim Fname1 As String, Fname2 As String, Fname3 As String Dim Bk1 As String, Bk2 As String, Bk3 As String Worksheets("Display").Activate Pname1 = Worksheets("Display").Range("Path1") Fname1 = Worksheets("Display").Range("File1") Pname2 = Worksheets("Display").Range("Path2") Fname2 = Worksheets("Display").Range("File2") Pname3 = Worksheets("Display").Range("Path3") Fname3 = Worksheets("Display").Range("File3") Bk1 = Pname1 + "\" + Fname1 Bk2 = Pname2 + "\" + Fname2 Bk3 = Pname3 + "\" + Fname3 Workbooks.Open (Bk1) Set Wbk1 = ActiveWorkbook ActiveWindow.WindowState = xlMinimized Workbooks.Open (Bk2) Set Wbk2 = ActiveWorkbook ActiveWindow.WindowState = xlMinimized Workbooks.Open (Bk3) Set Wbk3 = ActiveWorkbook ActiveWindow.WindowState = xlMinimized ActiveWindow.WindowState = xlMaximized Worksheets("Display").Range("A24").Activate End Sub Thanks for any help! Cheryl |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
BeforeClose event help | Excel Programming | |||
BeforeClose Event | Excel Programming | |||
VBA Code req to close all workbooks | Excel Programming | |||
VBA Code req to close all workbooks | Excel Programming | |||
File won't close when "beforeclose" event is used. | Excel Programming |