Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jeremy Town
 
Posts: n/a
Default How can I convert tab delimited files to pipe delimited?

I currently have some .txt files which are tab delimited, and I need to
convert them so that they are pipe(|) delimited. Any ideas how to do this?
Excel seems to support comma, tab and space delimiting, not sure how to use
pipe or tilda.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default How can I convert tab delimited files to pipe delimited?

I'd copy the text files into their own folder--just in case!

Then run a macro like:

Option Explicit
Sub testme01()

Dim myFileNames As Variant
Dim wkbk As Workbook
Dim fCtr As Long
Dim myCDP As DocumentProperties

myFileNames = Application.GetOpenFilename("Text Files, *.Txt", _
MultiSelect:=True)

If IsArray(myFileNames) = False Then
Exit Sub
End If

For fCtr = LBound(myFileNames) To UBound(myFileNames)
Call DoTheWork(myFileNames(fCtr))
Next fCtr

End Sub

Sub DoTheWork(myFileName As Variant)

Dim FSO As Object
Dim RegEx As Object
Dim myFile As Object
Dim myContents As String

Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.fileexists(myFileName) = False Then
'Do nothing
Else
Set myFile = FSO.OpenTextFile(myFileName, 1, False)
myContents = myFile.ReadAll
myFile.Close

Set RegEx = CreateObject("VBScript.RegExp")
With RegEx
.Global = True
.IgnoreCase = False
.Pattern = vbTab
myContents = .Replace(myContents, "|")
End With

Set myFile = FSO.CreateTextFile(myFileName, True)
myFile.Write myContents
myFile.Close
End If

End Sub



Jeremy Town wrote:

I currently have some .txt files which are tab delimited, and I need to
convert them so that they are pipe(|) delimited. Any ideas how to do this?
Excel seems to support comma, tab and space delimiting, not sure how to use
pipe or tilda.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How can I convert tab delimited files to pipe delimited?

Did this solution work? Is there an easier answer? I am currently using
Office 2000 and am willing to update for this feature as a simple "save as"
option.

"Dave Peterson" wrote:

I'd copy the text files into their own folder--just in case!

Then run a macro like:

Option Explicit
Sub testme01()

Dim myFileNames As Variant
Dim wkbk As Workbook
Dim fCtr As Long
Dim myCDP As DocumentProperties

myFileNames = Application.GetOpenFilename("Text Files, *.Txt", _
MultiSelect:=True)

If IsArray(myFileNames) = False Then
Exit Sub
End If

For fCtr = LBound(myFileNames) To UBound(myFileNames)
Call DoTheWork(myFileNames(fCtr))
Next fCtr

End Sub

Sub DoTheWork(myFileName As Variant)

Dim FSO As Object
Dim RegEx As Object
Dim myFile As Object
Dim myContents As String

Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.fileexists(myFileName) = False Then
'Do nothing
Else
Set myFile = FSO.OpenTextFile(myFileName, 1, False)
myContents = myFile.ReadAll
myFile.Close

Set RegEx = CreateObject("VBScript.RegExp")
With RegEx
.Global = True
.IgnoreCase = False
.Pattern = vbTab
myContents = .Replace(myContents, "|")
End With

Set myFile = FSO.CreateTextFile(myFileName, True)
myFile.Write myContents
myFile.Close
End If

End Sub



Jeremy Town wrote:

I currently have some .txt files which are tab delimited, and I need to
convert them so that they are pipe(|) delimited. Any ideas how to do this?
Excel seems to support comma, tab and space delimiting, not sure how to use
pipe or tilda.


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I convert my Quatro Pro files to MS Excel files? James HW New Users to Excel 3 May 11th 06 04:42 PM
how do i convert Excel 2000 files to Excel 2003 njw Excel Discussion (Misc queries) 1 October 12th 05 09:43 PM
Import Pipe Delimited File, Parse out certian Fields, create new f StarBoy2000 New Users to Excel 4 July 17th 05 07:36 AM
Convert multiple XLS files to TXT finao Excel Discussion (Misc queries) 2 June 8th 05 03:14 PM
Must convert 500+ xls files to txt (tsv) KKramsch Excel Discussion (Misc queries) 1 January 5th 05 05:53 PM


All times are GMT +1. The time now is 01:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"