P
Patrick Kirk
Hi,
My program starts with a simple form to create a new workbook or open an
existing one. Once you do either, the form disappears and either opens or
starts an new workbook. Once you close either the newly created workbook or
the existing one, the form re-appears asking you the same question of
creating a new workbook and/or opening an existing one. If the user selects
to open an existing workbook and that workbook is the name of the previous
workbook he/she has opened prior, in actuality the workbook may very well
already be open but not active or visible. My code below checks if the
workbook is already opened and if so, closes it and re-opens it.
Problem:
If the workbook is open the code will close it and the program will go dead
stopping after (Workbooks(StrWkBk).Close savechanges:=False). Is there a way
to force the program/script to continue?
On Error resume next
ThisWorkbook.Activate
Workbooks(StrWkBk).Close savechanges:=False
Set wbResults1 = Workbooks.Open(StrName)
My program starts with a simple form to create a new workbook or open an
existing one. Once you do either, the form disappears and either opens or
starts an new workbook. Once you close either the newly created workbook or
the existing one, the form re-appears asking you the same question of
creating a new workbook and/or opening an existing one. If the user selects
to open an existing workbook and that workbook is the name of the previous
workbook he/she has opened prior, in actuality the workbook may very well
already be open but not active or visible. My code below checks if the
workbook is already opened and if so, closes it and re-opens it.
Problem:
If the workbook is open the code will close it and the program will go dead
stopping after (Workbooks(StrWkBk).Close savechanges:=False). Is there a way
to force the program/script to continue?
On Error resume next
ThisWorkbook.Activate
Workbooks(StrWkBk).Close savechanges:=False
Set wbResults1 = Workbooks.Open(StrName)