Hello,
I need to import text file to excel and rename the sheet to the name of the textfile using macro. I have the code for importing the text file but have no idea how to rename it to the filename. for example my file name is test.txt , how can i change the sheet1 to this test.txt and get the current time when importing. Below is my code, please help me to edit it to show the filename in the sheet and display the time in the sheet as well. thank you very much
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:%username%Desktop ", _
Destination:=Range("G1"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = True
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.Refresh BackgroundQuery:=False
End With
Configuration: Windows Vista Internet Explorer 7.0
KEEP THE ORIGINAL FILE SAFELY SOMEWHERE SO THAT IT CAN BE RETRIEVED IF THERE IS PROBLEM
|
Hi,
|
Reply to venkat1926
|
Hi,
|
Your url is
|