I have a simple Excel sheet that I want to save as a CSV-file (and then send as an attachment using Outlook). When done, I want the original Excel sheet to be active and close the CSV-file.
This part works, except I can not seem to close the CSV-file. If I try, Excel terminates.
Sub Save()
Dim ActBook As Workbook
Dim CurrentFile As String
Dim NewFile As String
CurrentFile = ThisWorkbook.FullName
NewFile = Application.DefaultFilePath & "\new.csv"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=NewFile, FileFormat:=xlTextWindows
Application.DisplayAlerts = True
Set ActBook = ActiveWorkbook
Workbooks.Open CurrentFile ' Make original file active
' ActBook.Close ' This does not work, Excel terminates
End Sub