当前位置:编程学习 > VB >>

请教这段vb读入excel数据的错误在哪儿?

我希望用将excel表格中的三个数据读进text.text 但执行以下代码后报错说“对象变量或with块变量未设置” 请问错在哪儿? Option Explicit Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlsheet As Excel.Worksheet Dim n As Integer Dim a(3) Dim b(3) ----------------------------------------- Private Sub Command9_Click() xlApp.Visible = False Set xlBook = xlApp.Workbooks.Open(App.Path & "\inputdata.XLS") Set xlsheet = xlBook.Worksheets(1) Text1.Text = Cells(1, 1).Value Text2.Text = Cells(1, 2).Value Text3.Text = Cells(1, 3).Value xlBook.Close xlApp.Quit Set xlApp = Nothing End Sub
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,