View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Adding text file to a user form?

Make sure the textbox property for multiline is set to true.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Use Low Level fileio

Private Sub CommandButton1_Click()
strFile = "C:\xltext\myfile.txt"
hFile = FreeFile

Open strFile For Input As hFile

Do While Not EOF(hFile)
Line Input #hFile, strLine
sStr = sStr & strLine & Chr(10)
Loop
Close #hFile
UserForm1.TextBox1.Text = sStr
End Sub


RBSmissert posted this like which has some added information on low level
file io

http://www.applecore99.com/gen/gen029.asp


Of course, if your text file is large, you may only want to read in a

couple
of lines


Private Sub CommandButton1_Click()
Dim strFile as String, hFile as long
Dim strLine as String, icnt as long
strFile = "C:\xltext\myfile.txt"
hFile = FreeFile

Open strFile For Input As hFile
icnt = 0
Do While icnt < 5
Line Input #hFile, strLine
sStr = sStr & strLine & Chr(10)
icnt = icnt + 1
Loop
Close #hFile
UserForm1.TextBox1.Text = sStr
End Sub

--
Regards,
Tom Ogilvy


"Chip" wrote in message
oups.com...
I'm not sure what you mean? How would I go about doing that? Any code
to get me started would be great.