VB操作excle提示用户定义类型未定义
我这段代码为什么一测试就提示 用户定义类型未定义(代码是网上找的),求哪位大侠帮忙啊Private Sub Command1_Click()
'引用 Microsoft Excel 11.0 Object Library
Dim xlsApp As Excel.Application
Dim eworkbook As Workbook
Dim eworksheet As Worksheet
Set xlsApp = New Excel.Application
Set eworkbook = xlsApp.Workbooks.Open( "D:\sp.xls ")
Set eworksheet = eworkbook.Sheets( "Sheet1 ")
With eworksheet
'1
.Cells(1, 1) = "1 "
.Cells(1, 2) = "2 "
.Cells(1, 3) = "3 "
'2
.Cells(2, 1) = "11 "
.Cells(2, 2) = "22 "
.Cells(2, 3) = "33 "
'3
.Cells(3, 1) = "111 "
.Cells(3, 2) = "222 "
.Cells(3, 3) = "333 "
End With
eworkbook.Save
eworkbook.Close
xlsApp.Quit
End Sub
--------------------编程问答-------------------- 要在菜单工程-引用里加入对excel的引用
补充:VB , 基础类