View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] DuyFinViet@gmail.com is offline
external usenet poster
 
Posts: 1
Default Auto Importing of new files

http://j-walk.com/ss/excel/tips/tip97.htm


Martin wrote:
Anybody who knows please help! Thanks.

"Martin" wrote:

I have the following codes written to ask my operator to select the file from
a folder and import it repeatively. Now I want the import to be automatic
after 1min and it will automatic import the newest file in the folder. How
should I do it? Thanks.

Sub ImportSlitting()

Dim myFileName As Variant

Do
myFileName = Application.GetOpenFilename( _
filefilter:="Text Files, *.Txt", Title:="Locate & Select
the Reel")
If myFileName = False Then
MsgBox "End of Import. Copy Data to Slitting Summary.xls" 'user
hit cancel
Else
With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;" & myFileName, _
Destination:=Range("A1"))

.Name = "107074 r02 s01-2006-04-18-0102 PM"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 9, 1, 9, 1, 9, 1, 9)
.TextFileFixedColumnWidths = Array(2, 8, 7, 6, 30, 5, 17, 6)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

End If

Loop Until myFileName = False

End Sub