I am opening a text file in Excel, making some changes to it, and trying to save it back in .txt format.
The problem is that I keep getting 2 user prompt boxes.
The first comes at the SaveAs command. It says "<filename> already exists. Do you want to replace it?

Then, when I try to close the worksheet, I get another box that says "Not in Excel Format. Do you want to Save". If I say 'Yes', then I get the whole Filename prompt box and I'm not even in the directory that I want to save it in.

How do I avoid these prompts?


Here is the code I am using

srcFolder = "C:\Scripts"
srcFilename = "spr_bat.txt"
Application.ScreenUpdating = False
ChDir (srcFolder)
Workbooks.OpenText FileName:=srcFolder + "\" + srcFilename, Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), Array(2, 1), _
Array(3, 3), Array(4, 1), Array(5, 1))
'
'
' < Here I have a lot of code making changes to the file>
'
'
ChDir (srcFolder)
ActiveWorkbook.SaveAs FileName:=srcFolder + "\" + srcFilename, FileFormat:=xlText, _
CreateBackup:=False
ChDir (objfolder)
ActiveWindow.Close ' This is where I get the not in Excel Format box