I have these codes-
Code: Select all
XL:=comobjactive("excel.application")
FullFileName:="C:\Users\htc\Desktop\important_data.txt"
XL.Application.Workbooks.OpenText(FullFileName), origin:=65001, StartRow:=1, DataType:=1, TextQualifier:=1, ConsecutiveDelimiter:=False, Tab:=tabD, Semicolon:=False, Comma:=csvD, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
return
When I run above codes, a text file named important_data.txt is imported into a new excel workbook, while I want to import it into the sheet3 of already opened Excel workbook.
Important_data.txt looks like this-
And when I import it into MS Excel using above codes, it imports the important_data.txt correctly into MS Excel, but it imports into new workbook. Please look at this screen shot-
In the above screen shot you can see that the file is imported correctly but it is imported into new workbook whose name is set important_data and the sheet’s name is also set important_data (as you can see the workbook name and sheet name in red circle in above image). I want that it should be imported into the already opened Excel workbook’s sheet3. Please look at this screen shot-
The above is the image of my default workbook in which I work. This workbook (my_regular_workbook.xlsx) remains opened all the time when I work. I want that important_data.txt should be imported into sheet3 of my this workbook.
Please tell me what modifications should we make into the codes to import the specific .txt file into already opened workbook?
I am attaching important_data.txt with this post.
Please help me.
Thanks a lot…