Solved

Open a Text File Using Open Method (Excel.Application) With A Space & Tab Delimiter

Posted on 2004-08-04
3
3,045 Views
Last Modified: 2013-12-25
Dear Expert,
          I need to open a text file in excel using the open method.
I need to know how to use the delimiter within the open method.
The delimiter required is a space and tab.

Can you please help.....Urgently.

This is what I have so far.

Set appExcel = CreateObject("excel.application")
Set objWorkbook = appExcel.Workbooks.Open(FileName, delimiter)
                                                         \
                                                          What do I do here?
Kind Regards
Claude B
                                                         
0
Comment
Question by:BushyC
  • 2
3 Comments
 
LVL 11

Expert Comment

by:Steiner
ID: 11724355
The delimiter can only be 1 character, not a sequence. If you provide more, only the first character will be used (at least in Excel97) To provide a user defined delimiter, use:

Application.Workbooks.Open filename:="e:\test\text.txt",format:=6,delimiter:="x"
0
 

Author Comment

by:BushyC
ID: 11732215
Steiner, thanks for the info above.
I did some research, and apparently, I should be using OpenText Method.
Still coming up with errors.

'Expected Function Or Variable'

Set appExcel = CreateObject("excel.application")

Set objWorkbook = appExcel.Workbooks.OpenText(FileName, ConsecutiveDelimiter:=False, Tab:=True, Space:=True)

Set wSheet = objWorkbook.Worksheets(1)

Cheers
Claude B
0
 
LVL 11

Accepted Solution

by:
Steiner earned 500 total points
ID: 11732981
I regularly don't use OpenText, but I'd think that this one would mean "Tab OR Space". Or is that what you wanted?

Another point is that OpenText is a method, so it has no return value, while Open is a function which returns a workbook object (don't ask me why this is so ;-)) But as a workaround, use this:

Application.Workbooks.OpenText FileName, ConsecutiveDelimiter:=False, Tab:=True, Space:=True
Set objWorkbook = ActiveWorkbook

Daniel
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question