Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Format changes from "General" to "Text" | Excel Discussion (Misc queries) | |||
Multiple "source" workbooks linked to single "destination" workboo | Excel Worksheet Functions | |||
how do I format some text....."abc123" into "abc 123" | Excel Discussion (Misc queries) | |||
Excel VBA to convert "dd.MM.yy" text to "dd/MM/yyyy" format date? | Excel Programming | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming |