|
-
Jul 12th, 2005, 08:55 AM
#1
Thread Starter
New Member
[RESOLVED] Saving text file without prompt
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
-
Jul 12th, 2005, 09:07 AM
#2
Lively Member
Re: Saving text file without prompt
Change as follows:
VB Code:
ChDir (srcFolder)
[COLOR=Red]Application.DisplayAlerts = False[/COLOR]
ActiveWorkbook.SaveAs FileName:=srcFolder + "\" + srcFilename, FileFormat:=xlText, _
CreateBackup:=False
ChDir (objfolder)
ActiveWindow.Close ' This is where I get the not in Excel Format box
[COLOR=Red]Application.DisplayAlerts = True[/COLOR]
-
Jul 12th, 2005, 09:41 AM
#3
Thread Starter
New Member
Re: Saving text file without prompt
I could have sworn that I tried the DisplayAlerts before, but you are right. It seems to be working now. Thank You.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|