我已经使用这个宏多年了,最近与之关联的宏按钮已停止执行代码。但是,我可以通过从开发人员选项卡中的宏列表中选择宏来运行宏。以这种方式执行此操作然而代码中断到最后并导致运行时错误'32809'应用程序定义或对象定义错误。 奇怪的是,我的同事坐在我旁边使用相同的文件,代码工作正常。
以下是在此行中向下打破的代码示例: 表( “前”)。选择
我在很多论坛上搜索过这个问题,并尝试按照建议删除* .exd文件,但这并没有解决问题。非常感谢任何帮助。
代码:
Sub Import()
Dim i As Integer
Application.ScreenUpdating = False
Sheets("Control").Visible = True
Sheets("DataDump").Visible = True
If Weekday(Date) = 2 Then
COB = Date
Else
COB = Date - 1
End If
Range("dc_COB_Current").Value = COB
Application.Calculation = xlCalculationManual
Dim xTime() As Date
Application.GoTo "dd_Control"
Set xRange = Range(Range("dd_Control"), Cells(Range("dd_Control").End(xlDown).Row, Range("dd_Control").End(xlToRight).Column))
EmptyRpts = 0
ReDim Preserve cn(1 To xRange.Rows.Count)
ReDim Preserve rs(1 To xRange.Rows.Count)
ReDim Preserve xTime(1 To xRange.Rows.Count)
For i = 1 To xRange.Rows.Count
If xRange(i, 2) = "Y" Then
cnOpen (i)
If xRange(i, 5).Value <> "ALL" Then
xRange(i, 8).Value = Get_Sql(xRange(i, 5), xRange(i, 6), xRange(i, 7))
Else
xRange.Worksheet.Calculate
End If
xTime(i) = Now
rs(i).Open xRange(i, 8).Value, cn(i), adOpenForwardOnly, , adAsyncExecute
End If
Next
TotState = 1
Do Until TotState = 0
TotState = 0
For i = 1 To xRange.Rows.Count
Select Case rs(i).STATE
Case Is = ObjectStateEnum.adStateClosed '0
Case Is = ObjectStateEnum.adStateConnecting '2
Case Is = ObjectStateEnum.adStateExecuting '4
Case Is = ObjectStateEnum.adStateOpen '1
xRange(i, 9).Value = (Now - xTime(i)) * 24 * 60 * 60
DataDrop i, xRange(i, 4)
rs(i).Close
cn(i).Close
End Select
TotState = TotState + rs(i).STATE
Next
Loop
Application.Calculation = xlCalculationAutomatic
Sheets("Front").Select
'Sheets("Control").Visible = xlSheetVeryHidden
'Sheets("DataDump").Visible = xlSheetVeryHidden
Application.ScreenUpdating = False
End Sub
答案 0 :(得分:1)
我遇到此错误并通过安装KB2553154解决。