PC Review


Reply
Thread Tools Rate Thread

Adding a new file extension for Pipe Delimited files

 
 
philipaaldridge@googlemail.com
Guest
Posts: n/a
 
      12th Jun 2007
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

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      12th Jun 2007
Phil,
Try this. You can change the last argument of GetOpenFilename to true (and
handle the array) to deal with multiple files names.

Private Sub CommandButton1_Click()
Dim FileName As Variant

FileName = Application.GetOpenFilename("Pipe Separated File (*.psv), *.psv",
, , , False)

If FileName <> False Then
Workbooks.OpenText FileName, xlDelimited, TextQualifier:=xlDoubleQuote,
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False,
Other:=True, OtherChar:="|"
End If

End Sub

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
philipaaldridge@googlemail.com
Guest
Posts: n/a
 
      12th Jun 2007
On 12 Jun, 09:30, "NickHK" <TungChe...@Invalid.com> wrote:
> Phil,
> Try this. You can change the last argument of GetOpenFilename to true (and
> handle the array) to deal with multiple files names.
>
> Private Sub CommandButton1_Click()
> Dim FileName As Variant
>
> FileName = Application.GetOpenFilename("Pipe Separated File (*.psv), *.psv",
> , , , False)
>
> If FileName <> False Then
> Workbooks.OpenText FileName, xlDelimited, TextQualifier:=xlDoubleQuote,
> Tab:=False, _
> Semicolon:=False, Comma:=False, Space:=False,
> Other:=True, OtherChar:="|"
> End If
>
> End Sub
>
> NickHK
>
> <philipaaldri...@googlemail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > 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

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      13th Jun 2007
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 ActiveSheet.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

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 12 Jun, 09:30, "NickHK" <TungChe...@Invalid.com> wrote:
> > Phil,
> > Try this. You can change the last argument of GetOpenFilename to true

(and
> > handle the array) to deal with multiple files names.
> >
> > Private Sub CommandButton1_Click()
> > Dim FileName As Variant
> >
> > FileName = Application.GetOpenFilename("Pipe Separated File (*.psv),

*.psv",
> > , , , False)
> >
> > If FileName <> False Then
> > Workbooks.OpenText FileName, xlDelimited,

TextQualifier:=xlDoubleQuote,
> > Tab:=False, _
> > Semicolon:=False, Comma:=False, Space:=False,
> > Other:=True, OtherChar:="|"
> > End If
> >
> > End Sub
> >
> > NickHK
> >
> > <philipaaldri...@googlemail.com> wrote in message
> >
> > news:(E-Mail Removed)...
> >
> >
> >
> > > 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pipe-Delimited CSv File stevieb Microsoft Excel Misc 3 7th Aug 2008 08:08 PM
How can I convert tab delimited files to pipe delimited? =?Utf-8?B?SmVyZW15IFRvd24=?= Microsoft Excel Misc 2 15th Nov 2007 04:29 PM
Pipe-delimited files into access db normalit@gmail.com Microsoft Access External Data 2 10th Oct 2006 09:26 AM
Pipe Delimited files with headers normalit@gmail.com Microsoft Access External Data 2 7th Sep 2006 09:36 PM
Pipe and comma delimited files =?Utf-8?B?TWFsY29sbSBNb3Jhbg==?= Microsoft Access External Data 1 15th Nov 2004 11:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:02 AM.