想请问一下各位大侠,我想用对话框选择word文件,然后并打开这个word文件,怎么实现啊???

解决方案 »

  1.   

    http://bbs.csdn.net/topics/390435884
      

  2.   

    Option Explicit
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
    On Error GoTo EH
    With CommonDialog1
        .Filter = "Word file(*.doc)|*.doc"
        .CancelError = True
        .ShowOpen
        
        ShellExecute Me.hwnd, "", .FileName, "", "", 1
    End With
    Exit SubEH:
        If Err.Number = 32755 Then Exit Sub
        
        MsgBox "Realtime Error: " & Err.Number & vbCrLf & Err.Description
    End Sub
      

  3.   

    楼主说的是不是文件打开方式?默认doc、docx文件关联都是?直接双击即可。或者shell word.exe即可。