You can use either of these to do what you asked (note that **no** scripting
libraries are required)...
Sub FillTextBox()
Dim FileNum As Long
Dim TotalFile As String
Dim PathFileName As String
PathFileName = "c:\temp.txt"
FileNum = FreeFile
Open PathFileName For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
TextBox1.Text = TotalFile
End Sub
Sub FillListBox()
Dim X As Long
Dim FileNum As Long
Dim TotalFile As String
Dim PathFileName As String
Dim Records() As String
PathFileName = "c:\temp.txt"
FileNum = FreeFile
Open PathFileName For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
Records = Split(TotalFile, vbNewLine)
For X = 0 To UBound(Records)
If Len(Records(X)) Then ListBox1.AddItem Records(X)
Next
End Sub
Rick
"PcolaITGuy" <(E-Mail Removed)> wrote in message
news:423B4F7E-6390-49A5-93EF-(E-Mail Removed)...
>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
>
>
|