Solved

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

Posted on 2004-08-04
3
3,046 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
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…

733 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