Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

saving to pipe delimited textfile

Status
Not open for further replies.

rhammers

Programmer
Aug 14, 2001
2
US
I have a typical 10 column spreadsheet that I need to save as a pipe delimited textfile. In addition I can't have the double quote characters around the fields in the textfile. I've written the code to get it saved as a textfile but it saves it as a csv with quotes. Anyone have any samples that may help with this?
thanks!
 
try this code, I think I've interpreted "Pipe Delimited" correctly.

Code:
Dim write_st As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
to_file = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
Open to_file For Output As #1
For Each rw In ActiveSheet.UsedRange.Rows
    write_st = ""
    For i = 1 To 10
        Select Case i
            Case Is < 10
                write_st = write_st & rw.Cells(i) & &quot;|&quot;
            Case Else
                write_st = write_st & rw.Cells(i)
            End Select
        Next
    Print #1, write_st
    Next
Close
End Sub

Any use? SuperBry!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top