Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
close workbooks before opening another workbook
I believe I may have asked this question before, but I can't seem to find the
question or a response to it. Here it is: I have a large Excel Workbook that I want to have open first before opening two other files that link to this one. I want to write a macro that will close any open workbooks when this one is open. I tried an IF statement but my programming skills are limited thus far and I don't think I wrote the correct code. Will someone please help? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
close workbooks before opening another workbook
Hi Rob,
Try: '============= Private Sub Workbook_Open() Dim WB As Workbook For Each WB In Application.Workbooks If WB.Name < Me.Name Then WB.Close SaveChanges:=True 'Or False? End If Next WB End Sub '<<============= This is workbook event code and should be pasted into the workbook's ThisWorkbook module *not* a standard module or a sheet module --- Regards, Norman "Rob" wrote in message ... I believe I may have asked this question before, but I can't seem to find the question or a response to it. Here it is: I have a large Excel Workbook that I want to have open first before opening two other files that link to this one. I want to write a macro that will close any open workbooks when this one is open. I tried an IF statement but my programming skills are limited thus far and I don't think I wrote the correct code. Will someone please help? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Close form automatically upon opening workbook | Excel Discussion (Misc queries) | |||
Update workbook links without opening all workbooks | Excel Discussion (Misc queries) | |||
why do all excel worksheets/workbooks close when I close one? | Excel Discussion (Misc queries) | |||
How to close specific workbook not all active workbooks? | Excel Programming |