请问如何在form中单击一个label或图标调出word文档?

解决方案 »

  1.   

    strPath = VBA.Trim(lblPath.Caption)intPathLen = VBA.InStrRev(strPath, "\")
    strPathName = VBA.Left(strPath, intPathLen - 1)
            
    rc = ShellExecute(0, "open", strPath, "", strPathName, 1)
            
    If Not rc > 32 Then
        MsgBox "Open File False!", vbInformation, Me.Caption
    End IfPrivate 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 Long
      

  2.   

    如果文件关联正常的话Private Const SW_MAXIMIZE = 3
    Private Const SW_MINIMIZE = 6
    Private Const SW_NORMAL = 1
    Private Const SW_HIDE = 0Private 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()
    ShellExecute 0, "open", "c:\words\1.doc", vbNullString, vbNullString, SW_MAXIMIZE
    End Sub