Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default format columns as Text while using "Workbooks.OpenText"

Hi,

I am writing code to import text files and set column formats in Office XP.

I tried (goal is to set column 1 and 6 to Text Format):

Workbooks.OpenText Filename:=.FoundFiles(i), startrow:=2,
DataType:=xlDelimited, _
Tab:=True, FieldInfo:=Array(Array(1, 2), Array(6, 2))

With this, Column 1 and 2 become Text instead of 1 and 6. I want to format
the columns properly before I bring any data in - so formatting after the
import is too late for my data.

What am I doing wrong?

Thanks,
Brij


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default format columns as Text while using "Workbooks.OpenText"

Array is row, column; you have column, Row
I would format columns before importing data.

Columns("B:B").NumberFormat = "@"
Columns("F:F").NumberFormat = "@"

"BS" wrote:

Hi,

I am writing code to import text files and set column formats in Office XP.

I tried (goal is to set column 1 and 6 to Text Format):

Workbooks.OpenText Filename:=.FoundFiles(i), startrow:=2,
DataType:=xlDelimited, _
Tab:=True, FieldInfo:=Array(Array(1, 2), Array(6, 2))

With this, Column 1 and 2 become Text instead of 1 and 6. I want to format
the columns properly before I bring any data in - so formatting after the
import is too late for my data.

What am I doing wrong?

Thanks,
Brij



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default format columns as Text while using "Workbooks.OpenText"

Joel,

The ref manual tells me that this Array format is (Column you want to
format, constant that represents format choice).

Text is xlTextFormat which has a value of 2. So I thought this Array(6, 2)
should have worked.

Thx for responding,

Brij

"Joel" wrote in message
...
Array is row, column; you have column, Row
I would format columns before importing data.

Columns("B:B").NumberFormat = "@"
Columns("F:F").NumberFormat = "@"

"BS" wrote:

Hi,

I am writing code to import text files and set column formats in Office
XP.

I tried (goal is to set column 1 and 6 to Text Format):

Workbooks.OpenText Filename:=.FoundFiles(i), startrow:=2,
DataType:=xlDelimited, _
Tab:=True, FieldInfo:=Array(Array(1, 2), Array(6, 2))

With this, Column 1 and 2 become Text instead of 1 and 6. I want to
format
the columns properly before I bring any data in - so formatting after the
import is too late for my data.

What am I doing wrong?

Thanks,
Brij





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
Format changes from "General" to "Text" GARY Excel Discussion (Misc queries) 2 March 1st 09 10:18 AM
Multiple "source" workbooks linked to single "destination" workboo DAVEJAY Excel Worksheet Functions 1 September 17th 07 05:33 PM
how do I format some text....."abc123" into "abc 123" [email protected] Excel Discussion (Misc queries) 3 August 8th 07 12:11 AM
Excel VBA to convert "dd.MM.yy" text to "dd/MM/yyyy" format date? Paul J[_2_] Excel Programming 4 July 11th 07 11:32 AM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM


All times are GMT +1. The time now is 10:26 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"