ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to use Opentext method with xlFixedWidth? (https://www.excelbanter.com/excel-programming/293256-how-use-opentext-method-xlfixedwidth.html)

Together[_8_]

How to use Opentext method with xlFixedWidth?
 
Hi, everybody,

I want to import a text file into excel file, and I can use opentex
method. But the problem is that I want to convert each column in tex
file into one column in excel file. So I can use xlFixedWidt
parameter. But I do not know to fix the width ( I hope the width is on
character, the minimum). If I write code like these:

Workbooks.opentext Filename:=DaSourceBefore & DaSourceFile, _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlFixedWidth, _

Width :=1

TextQualifier:=xlTextQualifierSingleQuote


It can not work. Please help me. Thanks

--
Message posted from http://www.ExcelForum.com


BrianB

How to use Opentext method with xlFixedWidth?
 
Can you not set the macro recorder and then open the file to get th
code

--
Message posted from http://www.ExcelForum.com


shockley

How to use Opentext method with xlFixedWidth?
 
Do the import manually with the macro recorder turned on. That way you can
see and adjust graphically how Excel is splitting the text file into
columns. Then recover and edit the code in the vb editor.

HTH,
Shockley


"Together " wrote in message
...
Hi, everybody,

I want to import a text file into excel file, and I can use opentext
method. But the problem is that I want to convert each column in text
file into one column in excel file. So I can use xlFixedWidth
parameter. But I do not know to fix the width ( I hope the width is one
character, the minimum). If I write code like these:

Workbooks.opentext Filename:=DaSourceBefore & DaSourceFile, _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlFixedWidth, _

Width :=1

TextQualifier:=xlTextQualifierSingleQuote


It can not work. Please help me. Thanks.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com