如何用VB打开指定的EXCEL工作簿

2024-11-07 11:22:20
推荐回答(3个)
回答(1):

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 Long
Const SW_SHOWMAXIMIZED = 3

Private Sub List1_DblClick()
If List1.Text <> "" Then
ShellExecute Me.hwnd, "open", "d:\cw\" & List1.Text, "", "", SW_SHOWMAXIMIZED
End If
End Sub

回答(2):

用shell打开excel文件?
Private Sub List1_DblClick()
Shell "d:\cw\" & List1.List(List1.ListIndex)

End Sub

回答(3):

Private Sub Command4_Click()
Dim ExcelApp As Object
Set ExcelApp = CreateObject("excel.application")
ExcelApp.Workbooks.Add "d:/1.xls"
ExcelApp.Visible = True
End Sub