Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto Importing of new files
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto Importing of new files
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
importing .prn files | Excel Discussion (Misc queries) | |||
Importing CSV files | Excel Discussion (Misc queries) | |||
importing XML, auto formatting | Excel Discussion (Misc queries) | |||
Importing .bas files | Excel Programming | |||
Importing files | Excel Programming |