Results 1 to 3 of 3

Thread: Use Custom Dialog to open text file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    75

    Question 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

  2. #2
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    shell it

    Shell "C:\winword.exe " & Filename
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    If you want to open the file using it's default program, check out this tip http://161.58.84.209/files/tip236.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width