I have a macro below that copies a worksheet to a new workbook and then saves that new workbook.
The macro runs fine, except if a workbook with the same name as the new workbook is trying to use is open. Then the macro halts with an error: "You cannot save this workbook with the same name as another open workbook..."
Could someone give me some code that will alert the user with the same message, but will not end the macro with the VB End Debug message. i.e. I would like to display the message and then just terminate the macro "legally".
Here is the macro:
========================================
Dim wbNew As Workbook, wbCur As Workbook
Set wbCur = ActiveWorkbook
ThisWorkbook.Worksheets("EIS Setup Worksheet").Copy
Set wbNew = ActiveWorkbook
With wbNew
.SaveAs Filename:=Range("Save_Name2") & ".xlsx"
End With
==========================================
Thanks,
Mikeg
The macro runs fine, except if a workbook with the same name as the new workbook is trying to use is open. Then the macro halts with an error: "You cannot save this workbook with the same name as another open workbook..."
Could someone give me some code that will alert the user with the same message, but will not end the macro with the VB End Debug message. i.e. I would like to display the message and then just terminate the macro "legally".
Here is the macro:
========================================
Dim wbNew As Workbook, wbCur As Workbook
Set wbCur = ActiveWorkbook
ThisWorkbook.Worksheets("EIS Setup Worksheet").Copy
Set wbNew = ActiveWorkbook
With wbNew
.SaveAs Filename:=Range("Save_Name2") & ".xlsx"
End With
==========================================
Thanks,
Mikeg