I have a Module that calls a sub that moves a sheet and saves the book as a txt file. When I run the code the first time, it works just fine. If I try to run it again without closing the book, excel crashes. I figure it has something to do with the way I am saving the content or moving the sheet, but I cannot seem to figure out why.
Here is the portion of the code it crashes on:
Any help or guidance is greatly appreciated. If you need the rest of the code, I will be happy to post it as well.
Thanks in advance
Here is the portion of the code it crashes on:
Code:
Sub output_to_txt()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets(sheet_from).Select
Sheets(sheet_from).Move
ActiveWorkbook.SaveAs Filename:= _
outputfpath & outfnameNX & ".txt", FileFormat:= _
xlTextPrinter, CreateBackup:=False
ActiveWindow.Close
End Sub
Any help or guidance is greatly appreciated. If you need the rest of the code, I will be happy to post it as well.
Thanks in advance