Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Ignoring code to shut a workbook if it is already shut
I have some coding which closes and saves workbooks;
Workbooks("Bund Current Payoff.xls").Close SaveChanges:=True etc but I want the code not to have an error and have a problem if the file has already been closed when the code is run. How do I get around this problem? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Ignoring code to shut a workbook if it is already shut
Test if the workbook is still open first:
Dim wbTest As Workbook on error resume next Set wbTest = Workbooks("Bund Current Payoff.xls") on error goto 0 If Not wbTest Is Nothing Then Workbooks("Bund Current Payoff.xls").Close SaveChanges:=True wbTest will be Nothing if it wasn't already open -- Allllen "Cammy" wrote: I have some coding which closes and saves workbooks; Workbooks("Bund Current Payoff.xls").Close SaveChanges:=True etc but I want the code not to have an error and have a problem if the file has already been closed when the code is run. How do I get around this problem? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA code is being deletd from WorkBook | Excel Discussion (Misc queries) | |||
Need to Improve Code Copying/Pasting Between Workbooks | Excel Discussion (Misc queries) | |||
copy and paste using code from workbook to workbook | Excel Discussion (Misc queries) | |||
Often-Used Code not working in a new Workbook | Excel Discussion (Misc queries) | |||
Stubborn toolbars in Excel | Excel Discussion (Misc queries) |