Re: Adding a new file extension for Pipe Delimited files
- From: "NickHK" <TungCheWah@xxxxxxxxxxx>
- Date: Wed, 13 Jun 2007 14:10:21 +0800
Here's one simple way. It assumes that are no "|" characters in any values.
If there are, or need other formatting (e.g. text quoted, dates delimited
etc) you can that your self.
Check that UsedRange returns what you expect in your situation. If not, use
another method to determine what to export. But you get the idea.
Private Sub CommandButton1_Click()
Dim rngRow As Range
Dim Temp As String
Dim FileNumber As Long
For Each rngRow In Active***.UsedRange.Rows
Temp = Temp & Join(Application.Transpose(Application.Transpose(rngRow)),
"|") & vbNewLine
Next
Temp = Left(Temp, Len(Temp) - Len(vbNewLine))
FileNumber = FreeFile
Open "C:\OutPipe.psv" For Output As #FileNumber
Print #FileNumber, Temp
Close #FileNumber
End Sub
NickHK
<philipaaldridge@xxxxxxxxxxxxxx> wrote in message
news:1181645086.161782.165460@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 12 Jun, 09:30, "NickHK" <TungChe...@xxxxxxxxxxx> wrote:(and
Phil,
Try this. You can change the last argument of GetOpenFilename to true
*.psv",handle the array) to deal with multiple files names.
Private Sub CommandButton1_Click()
Dim FileName As Variant
FileName = Application.GetOpenFilename("Pipe Separated File (*.psv),
TextQualifier:=xlDoubleQuote,, , , False)
If FileName <> False Then
Workbooks.OpenText FileName, xlDelimited,
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False,
Other:=True, OtherChar:="|"
End If
End Sub
NickHK
<philipaaldri...@xxxxxxxxxxxxxx> wrote in message
news:1181635561.047978.128870@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,
Does anybody know a method so that pipe-delimited-separator text files
can be recognised and handle like CSV files in much the same way ( but
without disturbing CSV handling) ?
My problem is that I have a high volume of standard CSV files and pipe
delimited files. At the moment I have to you the file -> import ->
delimited | method..
Can this be achieved by adding a new file extension, say *.PCSV which
open and handle like CSV files?
Cheers in advance.
Phil- Hide quoted text -
- Show quoted text -
That's great. Thanks for the swift response!! My issue now is that I
can open the .psv file, but when I come to save the document, it won't
allow me to keep the pipe delimited format. Would I need to create
another macro to save it as pipe delimited in exactly the same format?
And any idea's how?
Thanks again.
Phil
.
- References:
- Adding a new file extension for Pipe Delimited files
- From: philipaaldridge@xxxxxxxxxxxxxx
- Re: Adding a new file extension for Pipe Delimited files
- From: NickHK
- Re: Adding a new file extension for Pipe Delimited files
- From: philipaaldridge@xxxxxxxxxxxxxx
- Adding a new file extension for Pipe Delimited files
- Prev by Date: Re: Passing an Array between Forms?
- Next by Date: Re: Test condition never satisfied in loop
- Previous by thread: Re: Adding a new file extension for Pipe Delimited files
- Next by thread: hide option dialog box
- Index(es):