two different ways are shown in the following...
Option Explicit
Private Sub Command1_Click()
OpenShowFile
End Sub
Private Sub OpenShowFile()
On Error GoTo OpenShowFileError
Dim FName As String, FNumb As Integer
Dim FileContents As String
CD.CancelError = True
CD.Filter = "Text Files *.txt|*.txt"
CD.FileName = vbNullString
CD.ShowOpen
If CD.FileName = vbNullString Then Exit Sub
FName = CD.FileName
FNumb = FreeFile
Open FName For Input As #FNumb
FileContents = Input(FileLen(FName), #FNumb)
Close #FNumb
Text1.Text = FileContents
Exit Sub
OpenShowFileError:
If Err.Number = 32755 Then Exit Sub 'user pressed cancel
End Sub
Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
Offline 1,670 posts
since Mar 2009