I have a command button inside of a macro-enabled template that when clicked, does some events, saves as a .csv file, then quits/closes. I am receiving a Type Mismatch error. I've removed all extraneous code, leaving only the portions that I see as being responsible for the error. the file saves successfully, then the error pops up. Once you click Debug on the error, the editor flashes on the screen for a moment, then Excel closed. Any thoughts?
Code:
Sub cmdProcess_click()
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="\\v2\imports\CUPRC Templates\test - " & Format(Time, "h-mm-ssampm"), FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Saved = True
Application.DisplayAlerts = True
If Workbooks.Count < 2 Then
Application.Quit
Exit Sub
Else
ActiveWorkbook.Close
Exit Sub
End If
End Sub