View Single Post
 
Old 04-19-2013, 06:47 AM
vodkasoda vodkasoda is offline Windows Vista Office 2007
Novice
 
Join Date: Apr 2013
Location: Stowmarket, Suffolk, UK
Posts: 15
vodkasoda is on a distinguished road
Default Word 2007 VBA Program was timing out

I have a Word VBA program with the following code ...

Code:
    Set xlApp = CreateObject("Excel.Application")
    Set xlWB = xlApp.Workbooks.Open(xlAppFile)
    
    xlApp.Visible = True
    
    SetTimeouts 180000, 180000
    
    With xlWB.Worksheets(1)
        .Cells(mySessionNo + 1, 2).Activate
        While (myMOTM(0, 0) = "" Or myMOTM(1, 0) = "" Or myMOTM(2, 0) = "")
            myMOTM(0, 0) = .Cells(mySession + 1, 2).Value
            myMOTM(1, 0) = .Cells(mySession + 1, 3).Value
            myMOTM(2, 0) = .Cells(mySession + 1, 4).Value
        Wend
    End With
    
    xlWB.Close True
    xlApp.Quit
    
    Set xlWB = Nothing
    Set xlApp = Nothing
... this is the subroutine, cloned from a Microsoft page ...

Code:
Public Sub SetTimeouts(ByVal lngComponentBusy As Long, ByVal lngRequestPending As Long)

  App.OLEServerBusyTimeout = lngComponentBusy
  App.OLERequestPendingTimeout = lngRequestPending

End Sub
... but I am getting the error message "OBJECT REQUIRED".

I assume this is the "APP.", which has come straight from the MS page I got the code from, but "xlAPP" & "xlWB" give the same result ... what am I doing wrong ?!?
Reply With Quote