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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete first tab of first line in a text file

Status
Not open for further replies.

akaRose

Technical User
Feb 14, 2009
26
CA
Hello,

I'm having trouble figuring this one out. I have a text file, that will always have a tab before the first field header which shifts everything over when I import the file to Access. I'm looking for a way to get rid of this, but I'm not sure how to refer specifically to this tab only.

Here is the code I have in Access for opening the file, and making some other changes....

Dim FSO, objFile, RegEx, strDestin, strFile, strSource
Set FSO = CreateObject("Scripting.FileSystemObject")

Const ForReading = 1
strSource = "\\moh\mohshare\CDSD\PHL\Labware Data Import\TB_Import_2010-06-10(raw)_2.txt"
strDestin = "C:\test.txt"
Set objFile = FSO.OpenTextFile(strSource, ForReading)

strFile = objFile.ReadAll
objFile.Close


strFile = Replace(strFile, Chr(13) & Chr(10), "xxxxxx")
strFile = Replace(strFile, "xxxxxx" & Chr(9), Chr(10))
strFile = Replace(strFile, "xxxxxx", " ")


Set objFile = FSO.CreateTextFile(strDestin, True)
objFile.Write strFile
objFile.Close



Any help is much appreciated!! Thanks
 
Something like this ?
strFile = objFile.ReadAll
If Left(strFile, 1) = Chr(9) Then strFile = Mid(strFile, 2)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That worked perfectly - much appreciated!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top