这段程序为什么已经能看到excel一瞬间被打开,但马上又自动关闭了?
Private Sub Command1_Click()
Dim xlApp As Object
Set xlApp = GetObject( "e:\book3.xls ")
xlApp.Application.Visible = True
End Sub
[解决办法]
用这个
Private Sub Command1_Click()
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlQuery As Excel.QueryTable
Set xlApp = CreateObject( "Excel.Application ")
Set xlBook = Nothing
Set xlSheet = Nothing
Set xlBook = xlApp.Workbooks().Add
Set xlSheet = xlBook.Worksheets( "sheet1 ")
xlApp.Visible = True
End Sub