Avinash Chugani
Avinash Chugani

Reputation: 13

excel macro runs but results in a Run time error '32809' application-defined or object defined error

I have been using this macro for years now and just recently the macro button associated with it has stopped executing the code. However, I am able to run the macro by selecting it from the list of macros in the developer tab. Doing it this way works however the code breaks towards the end and results in a Run time error '32809' application-defined or object defined error. The weird thing is the code works fine for my co worker seated right next to me using the same file.

Here is an example of the code which breaks towards the bottom at this line: Sheets("Front").Select

I have searched this issue on many forums and have tried deleting the *.exd files as suggested but this does not solve the issue. Any help with this is greatly appreciated.

Code:

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

Upvotes: 0

Views: 2003

Answers (1)

Eduardo Silvino
Eduardo Silvino

Reputation: 11

I had this error and resolved by installing the KB2553154.

Upvotes: 1

Related Questions