Opening files automatically with Import Text File dialog box

J

Jim P

I would like to eliminate the requirement to have a user
click on the Import button during VBA control of the
Import Text File dialog box. This will facilitate the
automatic processing of sequentially numbered files. I
would appreciate any suggestions. Here's a simplified
listing of the code I'm using.

Sub ImportOrigData()
'
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("OrigDataFile").Select
Range("A10").Select

Dim sText As String
For DOY = 147 To 149 ' first and last day of year to be
processed

sText = "TEXT;IA" & DOY & ".03R"

With Selection.QueryTable
.Connection = sText
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.Refresh BackgroundQuery:=False
End With
' Here I goto other processing subroutines
' then save to a unique DOY.xls file
Next DOY
End Sub
 
Top