Solved

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

Posted on 2004-08-04
3
3,048 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

617 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