Imports Microsoft.Office.Core
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myapp As Excel.Application
Dim mybook As Excel.Workbook
Dim mysheet As Excel.Worksheet
Dim filename As String
filename = "E:\vb2010\4\13.xlsx"
myapp = CreateObject("Excel.application")
myapp.Visible = False
mybook = myapp.Workbooks.Open(filename)
mysheet = mybook.Worksheets("sheet1")
myapp.Quit()
mysheet = Nothing
mybook = Nothing
myapp = Nothing
End Sub
End Class
运行时出现错误:
检查异常的ErrorCode 属性以确定COM对象返回的HRESULT.
[此贴子已经被作者于2021-11-5 09:01编辑过]