+ Reply to Thread
Results 1 to 3 of 3

Save As Text file

  1. #1

    Save As Text file

    Hi NG,
    Would appreciate any assistance with this one.
    I have searched the NG and not coming up with the right result I need.
    I have the following code:

    Sub SaveAsTxt()

    Sheets("Output").Select
    Range("A2").Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    Application.CutCopyMode = False

    ActiveWorkbook.SaveAs Filename:="C:\Sales\" & "Sales" & Format(Now,
    "yyyymmddhhmm") & ".txt", FileFormat:=xlText, _
    CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False

    Sheets("IMPUT").Select
    Range("A2").Select

    End Sub

    the resulting output is as a TAB delimited text file.
    I require COMMA ( , ) delimited, and contents with Double Quotes (""),
    including blank fields.

    Thanks in advance.
    Cheers Paul


  2. #2
    Tim Williams
    Guest

    Re: Save As Text file

    Need to use "csv" file format instead of just txt (FileFormat:=xlCSV)

    Tim.

    <[email protected]> wrote in message
    news:[email protected]...
    > Hi NG,
    > Would appreciate any assistance with this one.
    > I have searched the NG and not coming up with the right result I
    > need.
    > I have the following code:
    >
    > Sub SaveAsTxt()
    >
    > Sheets("Output").Select
    > Range("A2").Select
    > Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    > Selection.Copy
    > Workbooks.Add
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    >
    > ActiveWorkbook.SaveAs Filename:="C:\Sales\" & "Sales" & Format(Now,
    > "yyyymmddhhmm") & ".txt", FileFormat:=xlText, _
    > CreateBackup:=False
    > ActiveWorkbook.Close SaveChanges:=False
    >
    > Sheets("IMPUT").Select
    > Range("A2").Select
    >
    > End Sub
    >
    > the resulting output is as a TAB delimited text file.
    > I require COMMA ( , ) delimited, and contents with Double Quotes
    > (""),
    > including blank fields.
    >
    > Thanks in advance.
    > Cheers Paul
    >




  3. #3

    Re: Save As Text file

    Thanks Tim, that's a help.
    Cheers Paul

    Tim Williams wrote:
    > Need to use "csv" file format instead of just txt (FileFormat:=xlCSV)
    >
    > Tim.
    >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1