首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

这段程序为什么已经能看到excel一瞬间被打开,但马上又自动关闭了?解决办法

2012-01-16 
这段程序为什么已经能看到excel一瞬间被打开,但马上又自动关闭了?PrivateSubCommand1_Click()DimxlAppAsOb

这段程序为什么已经能看到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

热点排行
Bad Request.