VB 如何打开Excel2010版本?
最近在网上找了在VB中打开EXCEL的代码,结果在Excel2003版本中可以顺利的打开Excel(以前安装的是2003版本),如今安装了Excel2010版本,就提示 "提示:请先安装Excel办公软件" ,如下是代码(事先已在VB中引用 “工程(P)”—“引用(N)”—引用项目 Microsoft Excel 14.0 Object Library Microsoft Office 14.0 Object Library)Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet1 As Object
Sub ConnectExcel() '连接Excel
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err Then
Err.Clear
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
If Err Then MsgBox "提示:请先安装Excel办公软件"
End If
Set xlBook = xlApp.Workbooks.Add
xlApp.DisplayAlerts = False
xlBook.SaveAs "演示.xls"
xlApp.DisplayAlerts = True
End Sub
请教高手,如何解决!