The macro was working before but now it crashes on step "'3. Save new workbook in specified file and close copy".
The address was confirmed in immediate window and looks correct
?Worksheets(Sheet9.Name).Range("C4")&Range("E51")
D:\Test items\Memos\1 Pending\2022-10-16-Name--Memo-20.xlxs
However, it saves the file as File for type and then crashes excel
"D:\Test items\Memos\1 Pending\6D9D5C40"
Here is the Macro any Ideas why it would continue to crash??
Dim path As String
path = Worksheets(Sheet9.Name).Range("C4")
Dim memono As Long
memono = Range("A1")
Dim fname As String
fname = Range("E39")
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Memo cannot be changed. Review all and copy to ICHRT before submitting. Click Yes to Save & no to continue working", vbYesNo, "REVIEW MEMO & SAVE")
If Answer = vbYes Then
Application.DisplayAlerts = False
'1. Create copy of Memo in a new Workbook
Worksheets(Sheet4.Name).Visible = True
Worksheets(Array(Sheet1.Name, Sheet4.Name)).Copy
Worksheets(Sheet4.Name).Visible = False
'2. Remove Buttons from copy
'3. Save new workbook in specified file and close copy
With ActiveWorkbook
.SaveAs Filename:=path & fname, FileFormat:=51
.Close
End With
'4. Hide Sheet
Worksheets(Sheet4.Name).Visible = False
'5. Clear Template
Range("C8:L8").ClearContents
Range("C10:L10").ClearContents
Range("C12:L12").ClearContents
Range("C14:L14").ClearContents
Range("C16:L16").ClearContents
Range("C18:L18").ClearContents
Range("C20:H20").ClearContents
'6. update Memo number on template
Sheets(Sheet1.Name).Unprotect Password:=""
Range("A1") = memono + 1
Range("I20:J20").ClearContents
Sheets(Sheet1.Name).Protect Password:=""
'7. Save Template
ThisWorkbook.Save
Application.DisplayAlerts = True
'8.Message Process complete
MsgBox "The Memo has been saved and is pending review. You can now close the Memo Template"
Else
Exit Sub
End If
End Sub
The address was confirmed in immediate window and looks correct
?Worksheets(Sheet9.Name).Range("C4")&Range("E51")
D:\Test items\Memos\1 Pending\2022-10-16-Name--Memo-20.xlxs
However, it saves the file as File for type and then crashes excel
"D:\Test items\Memos\1 Pending\6D9D5C40"
Here is the Macro any Ideas why it would continue to crash??
Dim path As String
path = Worksheets(Sheet9.Name).Range("C4")
Dim memono As Long
memono = Range("A1")
Dim fname As String
fname = Range("E39")
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Memo cannot be changed. Review all and copy to ICHRT before submitting. Click Yes to Save & no to continue working", vbYesNo, "REVIEW MEMO & SAVE")
If Answer = vbYes Then
Application.DisplayAlerts = False
'1. Create copy of Memo in a new Workbook
Worksheets(Sheet4.Name).Visible = True
Worksheets(Array(Sheet1.Name, Sheet4.Name)).Copy
Worksheets(Sheet4.Name).Visible = False
'2. Remove Buttons from copy
'3. Save new workbook in specified file and close copy
With ActiveWorkbook
.SaveAs Filename:=path & fname, FileFormat:=51
.Close
End With
'4. Hide Sheet
Worksheets(Sheet4.Name).Visible = False
'5. Clear Template
Range("C8:L8").ClearContents
Range("C10:L10").ClearContents
Range("C12:L12").ClearContents
Range("C14:L14").ClearContents
Range("C16:L16").ClearContents
Range("C18:L18").ClearContents
Range("C20:H20").ClearContents
'6. update Memo number on template
Sheets(Sheet1.Name).Unprotect Password:=""
Range("A1") = memono + 1
Range("I20:J20").ClearContents
Sheets(Sheet1.Name).Protect Password:=""
'7. Save Template
ThisWorkbook.Save
Application.DisplayAlerts = True
'8.Message Process complete
MsgBox "The Memo has been saved and is pending review. You can now close the Memo Template"
Else
Exit Sub
End If
End Sub