Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I like to specify what I want--and not let excel guess:
Option Explicit Sub testme01() Dim fName As String Dim myArray() As Variant Dim iCtr As Long Dim maxFields As Long maxFields = Worksheets(1).Columns.Count fName = "C:\sometextfile.txt" ReDim myArray(1 To maxFields, 1 To 2) For iCtr = 1 To maxFields myArray(iCtr, 1) = iCtr myArray(iCtr, 2) = 1 Next iCtr Workbooks.OpenText Filename:=fName, Origin:=437, _ StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _ ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, _ Comma:=True, Space:=False, Other:=False, _ FieldInfo:=myArray End Sub Ed wrote: I recorded a macro to open a text-type file (.rev extension) and then save it as an xls workbook. It works well. But I have a question regarding the conversion. The macro recorded Workbooks.OpenText Filename:=MyFile _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _ , Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ and follows with Array(x,1) up to 69,1. I understand this is one array for each column. But as recorded, this on ly works correctly if I have 69 (or less, I presume) columns, right? If one has more than 69 columns, am I going to miss data? Is there a better way to code this to make sure I catch every column? Thanks. Ed -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro to Export Active Cells, Comma Sep to .txt file | Excel Programming | |||
button that opens open dialogs but saves path to sheet | Excel Programming | |||
Excel saves CSV using semicolon(;) instead of comma(,) | Excel Programming | |||
how to get a macro to run when the file opens | Excel Programming |