Use Custom Dialog to open text file
I have created a button to open the common dialog control ShowOpen, i want to be able to select a text file and have it open up in word or notepad or whatever. I've got this which displays the data in a text control, but i can't figure out how to do open it in another application.
Private Sub cmdOpen_Click()
Dim Filenum As Integer
Dim Filename As String
On Error GoTo ExitNow
CommonDialog1.Filter = "All Files (*.*)|*.*|Text files|*.txt"
CommonDialog1.FilterIndex = 2
CommonDialog1.DefaultExt = "txt"
CommonDialog1.Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist Or cdlOFNNoReadOnlyReturn
CommonDialog1.DialogTitle = "Select the source File"
CommonDialog1.Filename = Filename
'Exit if the user presses cancel
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
Filename = CommonDialog1.Filename
'Read the file's contents into the control
Filenum = FreeFile()
Open Filename For Input As #Filenum
Text1.Text = Input$(LOF(Filenum), Filenum)
Close #Filenum
End Sub