im using commondialog, i want to open a .doc, or .txt, whatever.. and load it into a richtext box. but i always get errors.. anyone know how.. thanks
later
Printable View
im using commondialog, i want to open a .doc, or .txt, whatever.. and load it into a richtext box. but i always get errors.. anyone know how.. thanks
later
Try this:
Code:Private Sub Command1_Click()
Dim iFile As Integer
On Error GoTo User_Cancelled
With CommonDialog1
.CancelError = True
.DialogTitle = "Select a Text File.."
.Filter = "Txt Files (*.txt)|*.txt|Doc Files (*.doc)|*.doc"
.ShowOpen
iFile = FreeFile
Open .filename For Input As iFile
RichTextBox1.text = Input(LOF(iFile), iFile)
Close iFile
End With
User_Cancelled:
End Sub
That will only work with TXT files.
For opening TXT and RTF, you can use the LoadFile method.
I think it's:
If it's not LoadFile then it's FileLoad or OpenFile or FileOpen or maybe I'm just tired... :rolleyes:Code:' Text files:
RichTextBox1.LoadFile("C:\MyFile.txt", vbCFText)
' RichText files:
RichTextBox1.LoadFile("C:\MyFile.rtf", vbCFRTF)
yea.. i finally seen that loadfile. im a retard..
thanks
later