Display contents of text file in a listbox or textbox on Excel for
Hi,
- Add a reference to Microsoft Scripting Runtime library
- Set the textbox (say TExtbox1) 's Multiline property to True
Now the code:
Sub FillTextbox()
Dim fso As Scripting.FileSystemObject
Dim ts As TextStream
Dim filename As String
Dim fulltext As String
filename = "C:\credit.txt"
Set fso = New Scripting.FileSystemObject
Set ts = fso.OpenTextFile(filename, ForReading)
TextBox1 = ts.ReadAll
ts.Close
set ts=Nothing
set fso = nothing
End sub
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
"PcolaITGuy" wrote:
I have a macro that creates a text file (c:\temp.txt) with single entries per
line.
example: server1
server2
server3
server4
I would like to be able to retrieve the contents of this file into a listbox
or a textbox within an Excel VBA form. Seems simple enough but I cannot get
this to work.
Any suggestions?
Thanks in advance,
Scott
|