Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Importing Fixed Width File Macro


Hello everyone,

I'm trying to create a macro in which I import a FIXED width
file. The macro below works fine, but I have to import files
with various record sizes. So I might have 20 arrays sometimes
and sometimes 10 arrays. Is there a way to prompt me and
ask how many arrays there are in the input file? Let me know
if I should elaborate more on the problem. Any help would be
appreciated.

Thanks,
Himansu
--


Dim CellMatrixFile As String
Dim DeptMatrixFile As String

Dim SaveAsFile As String
Application.DisplayAlerts = False
Set OldSpreadSheet = ActiveWindow.ActiveSheet

CellMatrixFile = Application.GetOpenFilename("Matrix Files,*.matrix")

If CellMatrixFile < "False" Then
Workbooks.OpenText Filename:=CellMatrixFile, _
Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=
_
Array(Array(0, 2), Array(10, 1), Array(20, 1), Array(30, 1),
Array(40, 1) _
, Array(50, 1), Array(60, 1), Array(70, 1), Array(80, 1), Array(90,
1) _
, Array(100, 1), Array(110, 1), Array(120, 1), Array(130, 1),
Array(140, 1) _
, Array(150, 1), Array(160, 1), Array(170, 1), Array(180, 1),
Array(190, 1) _
, Array(200, 1), Array(210, 1), Array(220, 1), Array(230, 1),
Array(240, 1))
Else
Exit Sub
End If


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Importing Fixed Width File Macro

If the column widths are the same regardless of the number of files, just
use the one that handles the most columns for all.

--
Regards,
Tom Ogilvy


"Himansu" wrote in message
...

Hello everyone,

I'm trying to create a macro in which I import a FIXED width
file. The macro below works fine, but I have to import files
with various record sizes. So I might have 20 arrays sometimes
and sometimes 10 arrays. Is there a way to prompt me and
ask how many arrays there are in the input file? Let me know
if I should elaborate more on the problem. Any help would be
appreciated.

Thanks,
Himansu
--


Dim CellMatrixFile As String
Dim DeptMatrixFile As String

Dim SaveAsFile As String
Application.DisplayAlerts = False
Set OldSpreadSheet = ActiveWindow.ActiveSheet

CellMatrixFile = Application.GetOpenFilename("Matrix Files,*.matrix")

If CellMatrixFile < "False" Then
Workbooks.OpenText Filename:=CellMatrixFile, _
Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth,

FieldInfo:=
_
Array(Array(0, 2), Array(10, 1), Array(20, 1), Array(30, 1),
Array(40, 1) _
, Array(50, 1), Array(60, 1), Array(70, 1), Array(80, 1),

Array(90,
1) _
, Array(100, 1), Array(110, 1), Array(120, 1), Array(130, 1),
Array(140, 1) _
, Array(150, 1), Array(160, 1), Array(170, 1), Array(180, 1),
Array(190, 1) _
, Array(200, 1), Array(210, 1), Array(220, 1), Array(230, 1),
Array(240, 1))
Else
Exit Sub
End If




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
Problem Importing Fixed Width Data [email protected] New Users to Excel 7 September 15th 06 01:42 AM
Changing fixed width (column break) defaults when importing text NaughtonNJ Excel Discussion (Misc queries) 1 May 3rd 06 06:13 PM
Importing file with fixed width, multi-line records danmcgov Excel Discussion (Misc queries) 7 March 20th 06 08:05 PM
Basic Q: Field/Array info when importing fixed-width text files KR Excel Programming 0 March 1st 05 09:02 PM
Recording a macro to open a large fixed-width text file Lucie Harris Excel Programming 3 September 1st 04 02:23 AM


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