ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I read text file in an EXCEL SHEET (https://www.excelbanter.com/excel-programming/286466-how-do-i-read-text-file-excel-sheet.html)

AMIT

How do I read text file in an EXCEL SHEET
 
Hello,

With regards to EXCEL how we read the text file in EXCEL sheet using
MACRO.
The file is located in d:\Sql\Documents\Amit\log.txt.
I want to save the EXCEL sheet, and every time when I open this sheet
it reads this text file and displays the contents of this text file in
Excel Sheet.
I want to use MACRO for reading this text file.How I do that?

Thanks

Amit

Alexander[_4_]

How do I read text file in an EXCEL SHEET
 
fileName = "D:\Sql\Documents\Amit\log.txt"

Workbooks.OpenText FileName:=fileName

OR

Workbooks.OpenText FileName:=fileName, Origin:=xlWindows, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(0, 2), Array(10, 2). . .)


Alex


"AMIT" wrote in message
om...
Hello,

With regards to EXCEL how we read the text file in EXCEL sheet using
MACRO.
The file is located in d:\Sql\Documents\Amit\log.txt.
I want to save the EXCEL sheet, and every time when I open this sheet
it reads this text file and displays the contents of this text file in
Excel Sheet.
I want to use MACRO for reading this text file.How I do that?

Thanks

Amit




AMIT

How do I read and refreshes the information in the text file in an EXCEL SHEET,every time when I run macro
 
Hello,

Thanks for your information.
But I still need some more info about the problem.
Actually I want that every time when I run the macro, it refreshes the
information from the text file, from the following path
(d:\Sql\Documents\Amit\log.txt) and display its contents on the Excel
sheet. How should I record the macro in order to perform this
operation?


Best Regards

Amit.








"biju" wrote in message ...
Dear Amit

Pls. enable the macro record option from tools menu after opening excel and use the manual way of opening the text file
by listing only text files and selecting it..stop/close recording the macro after assigning a shortcut(keys) and thats it..

with regards
biju

Eg :
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/30/2003 by biju
'
' Keyboard Shortcut: Ctrl+l
'
ChDir "d:\Sql\Documents\Amit\"
Workbooks.OpenText Filename:="d:\Sql\Documents\Amit\log.txt", Origin:=xlWindows, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1))
End Sub



All times are GMT +1. The time now is 03:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com