程序代码:
Private fenshu As Integer Private ea As Excel.Application '代表excel程序 Private bzbg As Excel.Workbook '代表excelworkbook(也就是excel工作簿文件 .xls .xlsx) Private jdbg As Excel.Workbook '代表excelworkbook(也就是excel工作簿文件 .xls .xlsx) Private df As Long '得分临时变量 Private kd As String '考点 Private pf As Boolean '判分变量 Private bg As String '所在表格 Private wz As String '所在位置 Private sl As String Private Sub Command1_Click() Dim i As Long Dim ti As String 'excel题 Dim khd() As String '考核点数组 Dim xkhd() As String '小考核点数组 Dim weizhi() As String '批阅位置 Set ea = New Excel.Application 'ea 实例化 Set bzbg = ea.Workbooks.Open("D:\未识别\Excel\bzbg.xls") 'bzbg对象标准表格 Set jdbg = ea.Workbooks.Open("D:\未识别\Excel\jdbg.xls") 'jdbg对象解答表格 bg = "Sheet1" wz = "A1:A1" sl = "本月票房统计" Call E单元格内容(bg, wz, sl) Call 判分 MsgBox (pf) 'Debug.Print kd, fenshu On Error Resume Next '强制执行下一步 Set jdbg.Worksheets("Sheet1") = Nothing '关闭Sheet Set bzbg.Worksheets("Sheet1") = Nothing '关闭Sheet jdbg.Close '关闭解答文档 bzbg.Close '关闭标准文档 ea.Quit '退出Word应用程序对象 Set jdbg = Nothing '释放jdwd变量 Set bzbg = Nothing '释放bzwd变量 Set ea = Nothing '释放wa变量 End Sub Public Sub E单元格内容(bg As String, wz As String, sl As String) pf = True On Error Resume Next '强制执行下一步 If jdbg.Worksheets("" & bg & "").Range("" & wz & "").Text <> sl Then pf = False '不一致扣分 End Sub Public Sub 判分() '判分 If pf = True Then fenshu = fenshu + df If pf = False Then 'Call 结果输出(df & "分的" & kd) End If End Sub
[ 本帖最后由 yyh888 于 2015-5-25 14:09 编辑 ]