Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-04
3
Medium Priority
?
3,049 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 2000 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

730 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