Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Location
    Brantford, Ontario
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save .txt file without Save As prompts (Windows 2000)

    I am trying to automate a process that involves opening a text file in Excel, modifying the file then saving it again. Visual Basic code handles the opeing of the text file OK, but when I try to save, I am always prompted with a "Save As" window. As I am trying to automate, I don't want to have to provide input to the procedure via the "Save As" window, I just want the text file saved. Here's the code that works:

    Workbooks.OpenText Filename:="C:histxsource" & Parameter & ".txt", Origin:=xlWindows _
    , StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
    , Space:=False, Other:=False, FieldInfo:=Array(1, 2)

    Here's the code that doesn't:

    ActiveWorkbook.SaveAs Filename:="chistxsource" & Parameter & ".txt'

    Any suggestions?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Save .txt file without Save As prompts (Windows 2000)

    Instead of SaveAs, use

    ActiveWorkbook.Save

    followed by (if you want to close the document)

    ActiveWorkBook.Close SaveChanges:=False

  3. #3
    New Lounger
    Join Date
    Aug 2002
    Location
    Brantford, Ontario
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save .txt file without Save As prompts (Windows 2000)

    Thanks, I was sure I had tried that. I assumed that Excel had done some kind of conversion on the file upon importation and that I had to specify it as a text file. This is my first post to this board and I am impressed!

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save .txt file without Save As prompts (Windows 2000)

    If you are using SaveAs because you are changing something like the file name, then you can use:

    <pre> Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="chistxsource" & Parameter & ".txt"
    ApplicationDisplayAlerts = True
    </pre>

    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •