一个控件中的两个button对同一个excel进行查找数据的操作,看代码
Private Sub Command4_Click()Dim xlApp As Excel.Application '声明对象变量
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim OpenExecl As Long
Dim ExcelPath As String
Dim aaA As String
Dim Lane As Integer
Dim P As Integer
Dim HPHR As Integer
Lane = Val(LaneIO(0))
P = Val(HPIO(1))
HPHR = Val(HPHRIO(2))
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open("E:\WLR\VB\FPGA0910.xls") '打开存在的execl文件
xlApp.Visible = False '设置EXCEL对象可见(或不可见)
Set xlSheet = xlBook.Worksheets("Sheet1") '设置活动工作表
xlSheet.Activate '激活工作表
RCOUNT = xlApp.ActiveSheet.UsedRange.Rows.Count
中间的按照条件查找的代码没有贴出来
--------------------------------------------------------------------------------------------
Private Sub Command5_Click(Index As Integer)
Dim xlApp As Excel.Application '声明对象变量
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim OpenExecl As Long
Dim ExcelPath As String
Dim aaA As String
Dim Lane As Integer
Dim P As Integer
Dim HPHR As Integer
Lane = Val(LaneIO(0))
P = Val(HPIO(1))
HPHR = Val(HPHRIO(2))
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open("E:\WLR\VB\FPGA0910.xls") '打开存在的execl文件
xlApp.Visible = False '设置EXCEL对象可见(或不可见)
Set xlSheet = xlBook.Worksheets("Sheet4") '设置活动工作表
xlSheet.Activate '激活工作表
RCOUNT = xlApp.ActiveSheet.UsedRange.Rows.Count
中间的按照条件查找的代码没有贴出来
--------------------------------------------------------------------------------
相当于用两个按钮对同个excel的不同sheet进行了相同的条件查找,但是却报错了是为什么?错误提示见图片