为什么这个显示“xlsbook变量没定义”
Option Explicit
Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Private Sub Command1_Click()
Set xlApp = New Excel.Application
xlApp.Visible = False
Set xlbook = xlApp.Workbooks.Open(App.Path & "\1.xls")
Set xlsheet = xlbook.Worksheets(1)
If xlsbook.Sheets(1).Cells(1, 1) <> "序号" Or xlsbook.Sheets(1).Cells(1, 2) <> "商品名称" Or xlsbook.Sheets(1).Cells(1, 3) <> "价格" Then
MsgBox ""
End If
End Sub
[解决办法]
你上面定义的是
Dim xlbook As Excel.Workbook
没有‘s’