Hi All,
I am trying to automate one of my daily task which is to import a comma seperated file into a excel file using a text to column.
I have recorded the macros while doing that and got macros as follows
Sub test()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\pals\macros\test\pos\test.log", Destination:=Range("A1"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
i am able to achive the required excel file but the trouble is that i have keep the file as test.log.This is a daily generated file with data appended -- testddmm.log where dd is the date and mm is the month.i tried to create a variable
filename = "test" &Format(Date, "ddmm") & ".log"
but i am end up getting a error message like
runtime error 4.specified file is found
i will be having file generated daily into a folder with the date appended
like
test3003.log
test3103.log
test 0104.log
i have to pick the file generated with the current date and perform the text to column task using macros.
could anyone help me in fixing this issue.
I am trying to automate one of my daily task which is to import a comma seperated file into a excel file using a text to column.
I have recorded the macros while doing that and got macros as follows
Sub test()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\pals\macros\test\pos\test.log", Destination:=Range("A1"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
i am able to achive the required excel file but the trouble is that i have keep the file as test.log.This is a daily generated file with data appended -- testddmm.log where dd is the date and mm is the month.i tried to create a variable
filename = "test" &Format(Date, "ddmm") & ".log"
but i am end up getting a error message like
runtime error 4.specified file is found
i will be having file generated daily into a folder with the date appended
like
test3003.log
test3103.log
test 0104.log
i have to pick the file generated with the current date and perform the text to column task using macros.
could anyone help me in fixing this issue.