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!

setting workbook object to a vertical bar "¦" delimited file

Status
Not open for further replies.

scro11bar

Programmer
Oct 25, 2001
11
US
Hi,
Im trying to use an excel object to open a file thats delimited by the vertical bar - "|". But when I set the delimiter to "|" in the Open command, the file isn't delimited.

Here is a bit of the code...
----------------------------------------------
Dim excel_app As Excel.Application
Dim work_book As Excel.Workbook
Dim excel_file As String
Dim val As String

Set excel_app = New Excel.Application
excel_file = "c:\file.txt"

Set work_book = excel_app.Workbooks.Open(excel_file, , , , , , , , "|")
val = work_book.ActiveSheet.Cells(1, 1).Value
----------------------------------------------

When I print the val, I get the whole line "A|B|C|D|E|F..." instead of "A".
I tried using this code for tab delimited file and that seems to work. Anyone have any idea how I can set the workbook so that each cell contains the delimited values instead of the first cell containing the whole line?
Thanks in advance.

G. Rush
 
Hi Scrollbar

Try

Code:
Excel_App.Workbooks.OpenText FileName:=excel_file, _
                    Origin:=xlWindows, StartRow:=1, 
                 DataType:=xlDelimited, TextQualifier:= _
                 xlDoubleQuote, ConsecutiveDelimiter:=False, 
              OtherChar:="|"
[\code]

If not, record the opening text in excell and try to use the code.

Nath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top