Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default OpenText method not working

I am automating a text file from Word to Excel. When I try to open the text
file in Excel from Word using:

xlApp.Workbooks.OpenText Filename:= _
wdFile & ".txt", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False,
Comma:=False _
, Space:=True, Other:=False, TrailingMinusNumbers:=True

I get an error. If I delete everything except the filename and the origin,
it works correctly. However, I need to have the file delimited by spaces.
What is wrong with this?

Thanks, Pflugs
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default OpenText method not working

I would guess you are using late binding (GetObject or CreateObject), so
Try replacing xlDelimited with its value, 1


xlApp.Workbooks.OpenText Filename:= _
wdFile & ".txt", Origin:=437, _
StartRow:=1, DataType:=1, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, _
TrailingMinusNumbers:=True

--
Regards,
Tom Ogilvy



"Pflugs" wrote in message
...
I am automating a text file from Word to Excel. When I try to open the

text
file in Excel from Word using:

xlApp.Workbooks.OpenText Filename:= _
wdFile & ".txt", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False,
Comma:=False _
, Space:=True, Other:=False, TrailingMinusNumbers:=True

I get an error. If I delete everything except the filename and the

origin,
it works correctly. However, I need to have the file delimited by spaces.
What is wrong with this?

Thanks, Pflugs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default OpenText method not working

Thanks, Tom. I ended up just rewriting the macro in Excel. The text file
imported a lot nicer than I thought it would, and I achieved much better
results. Thanks for your time.

Pflugs

"Tom Ogilvy" wrote:

I would guess you are using late binding (GetObject or CreateObject), so
Try replacing xlDelimited with its value, 1


xlApp.Workbooks.OpenText Filename:= _
wdFile & ".txt", Origin:=437, _
StartRow:=1, DataType:=1, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, _
TrailingMinusNumbers:=True

--
Regards,
Tom Ogilvy



"Pflugs" wrote in message
...
I am automating a text file from Word to Excel. When I try to open the

text
file in Excel from Word using:

xlApp.Workbooks.OpenText Filename:= _
wdFile & ".txt", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False,
Comma:=False _
, Space:=True, Other:=False, TrailingMinusNumbers:=True

I get an error. If I delete everything except the filename and the

origin,
it works correctly. However, I need to have the file delimited by spaces.
What is wrong with this?

Thanks, Pflugs




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
opentext method [email protected] Excel Programming 0 January 31st 06 07:52 AM
OpenText Method JH Excel Programming 2 August 24th 05 11:42 PM
OpenText Method failure Bryan Dickerson Excel Programming 9 April 13th 05 09:29 PM
How to use Opentext method with xlFixedWidth? Together[_8_] Excel Programming 2 March 3rd 04 03:27 PM
Pass string as Parameter in OpenText method No Name Excel Programming 0 January 8th 04 06:22 AM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"