none
> -2147417856, Automation Error System Call Failed, Office 2010 RRS feed

  • Question

  • Hi,
    could not fix this...

    > -2147417856, Automation Error System Call Failed, Office 2010

    MACRO.XLSM
    ...
    FOR I = 1 TO X
    SEND_EMAIL (....)
    
    NEXT I
    Function SEND_EMAIL(....)
    90    lcAppName = "Outlook.Application"
    95    ll_ERR_TRY = True
    100   Set oOLApp = GetObject(, lcAppName) ' <------- -2147417856, Automation error System call failed
    105   ll_ERR_TRY = False
    110   If oOLApp Is Nothing Then GoTo LBL_xPAC_END
    ....
    Exit Function
    LBL_xPAC_ERR:
    If ll_ERR_TRY And (ln_TRY_CNT <= 3) Then
        ln_TRY_CNT = ln_TRY_CNT + 1
        DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents
        Resume  ' <------- -RETRY DOES NOT HELP
    End If


    dBase,FoxPro,MS Access 2003,(2010=Not rec.),Office 2010+ACC.2013 ,Symbian C++, AC.2013.SystemResource.GetCurrentFreeSize=?

    Monday, February 5, 2018 2:20 PM

All replies

  • Hello PACALA_BA,

    Is the Outlook opened? If you failed to get object, what about create the object if failing to get?

    Could you test if below code could work for you?

    Sub Test()
    For i = 2 To 3
    SEND_EMAIL i
    Next i
    End Sub
    
    Function SEND_EMAIL(i As Variant)
    
       lcAppName = "Outlook.Application"
       ll_ERR_TRY = True
       On Error Resume Next
       Set oOLApp = GetObject(, lcAppName)
       If Err.Number <> 0 Then
        Err.Clear
        Set oOLApp = CreateObject(lcAppName)
       End If
       
       If Not oOLApp Is Nothing Then
        Set mail = oOLApp.CreateItem(olMailItem)
        mail.Subject = i
        mail.Display
       End If
      
    End Function
    
    
    

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 6, 2018 7:31 AM
  • Hi, thx

    Is the Outlook opened?

    ......YES

    OLK.2010.ThisOutlookSession.Timer or Manually
    
    Public Sub RUN_EXCEL()
    ...
    Set xlApp = CreateObject("excel.application")
    xlApp.Workbooks.Open "MACRO.xlsm"' <------------------ open EXCEL
    LBL_xPAC_END:
        Set xlApp = Nothing
        Exit Sub

    If you failed to get object, what about create the object if failing to get?

    ....THE SAME FAILURE

    or object CREATED , but with NO PROPERTIES, ....

    OBJECT BROWSER......<NO VARIABLES> !!!!!

    =================

    If excel started directly........OK, none errors

    If excel started from outlook.....they are this RANDOM errors, most cases if sending over 50 emails, if sending less emails, it works OK

    ===============


    dBase,FoxPro,MS Access 2003,(2010=Not rec.),Office 2010+ACC.2013 ,Symbian C++, AC.2013.SystemResource.GetCurrentFreeSize=?

    Tuesday, February 6, 2018 9:42 AM
  • Hi

    RetVal = ShellExecute(MACRO.xlsm")...................OK, WITHOUT ERRORS yayhandclap.gifyayhandclap.gifyayhandclap.gif

    This .....RANDOM AUTOMATION ERROR  pullhair.gif

    , main-parameter how many emails sent.... shrug.gificonfused.gif

    Set xlApp = CreateObject("excel.application")
    xlApp.Workbooks.Open "MACRO.xlsm"' <------------------ open EXCEL


    dBase,FoxPro,MS Access 2003,(2010=Not rec.),Office 2010+ACC.2013 ,Symbian C++, AC.2013.SystemResource.GetCurrentFreeSize=?

    Tuesday, February 6, 2018 1:41 PM
  • Hello PACALA_BA,

    It seems that this error occurs once you open the workbook and run the macro from Outlook, right? How do you call the macro in workbook from Outlook?

    I tried to call the macro via Application.Run and it works me. I would suggest you take it as reference for testing.

    Sub Test2()
    Set xlApp = CreateObject("excel.application")
    xlApp.Workbooks.Open "C:\Users\Admin\Desktop\Book1.xlsm"
    'ThisWorkbook is the module name, Test is macro name
    xlApp.Run "ThisWorkbook.Test"
    End Sub

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 7, 2018 1:09 AM
  • Hi, thx

    Sometimes throws RANDOM errors, especially if sending more emails,,,,, sometimes without any errors, the issue persist a few months, before allways...OK

    MACRO.xlsm.....Direct starting without OUTLOOK CALLS.......OK

    It seems that this error occurs once you open the workbook and run the macro from Outlook, right?

    .......YES

    How do you call the macro in workbook from Outlook?

    .....HERE DOWN

    OLK.2010.ThisOutlookSession.Timer or Manually
    
    Public Sub RUN_EXCEL()
    ...
    Set xlApp = CreateObject("excel.application")
    xlApp.Workbooks.Open "MACRO.xlsm"' <------------------ open EXCEL
    LBL_xPAC_END:
        Set xlApp = Nothing
        Exit Sub
    
    

    and then , here MACRO with sending emails

    MACRO.XLSM
    ...
    FOR I = 1 TO X
    SEND_EMAIL (....)
    
    NEXT I
    Function SEND_EMAIL(....)
    90    lcAppName = "Outlook.Application"
    95    ll_ERR_TRY = True
    100   Set oOLApp = GetObject(, lcAppName) ' <------- -2147417856, Automation error System call failed
    105   ll_ERR_TRY = False
    110   If oOLApp Is Nothing Then GoTo LBL_xPAC_END
    ....
    Exit Function
    LBL_xPAC_ERR:
    If ll_ERR_TRY And (ln_TRY_CNT <= 3) Then
        ln_TRY_CNT = ln_TRY_CNT + 1
        DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents
        Resume  ' <------- -RETRY DOES NOT HELP
    End If
    
    


    dBase,FoxPro,MS Access 2003,(2010=Not rec.),Office 2010+ACC.2013 ,Symbian C++, AC.2013.SystemResource.GetCurrentFreeSize=?

    Wednesday, February 7, 2018 10:39 AM
  • Hello PACALA_BA,

    I failed to get new information from your newly shared code. It is same as your previous code.

    I failed to reproduce your issue since I'm still wondering how do you call the function.

    I could see opened the xlsm file but no code how to call the sub in it. 

    Besides, if you get error while sending more emails, I would suggest you declare oOLApp as a global variable so you do not need try to GetObject for it multiple times when calling SEND_EMAIL repeatedly.

    Best Regards,

    Terry



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 8, 2018 1:52 AM
  • Hi Terry , thx

    newly shared code...I CAN NOT SHARE ALL , OUTLOOK --~3000 ROWS, MACRO...~ 5000 ROWS iconfused.gif

     declare oOLApp as a global.........THE SAME WRONG AS BEFORE pullhair.gif

    if i open MACRO.XLSM with WIN32API.SHELLEXE.......ALL IS OK  woohoo.gif

    SUBMIT THIS ....Unexpected error pullhair.gifpullhair.gifpullhair.gif

    dBase,FoxPro,MS Access 2003,(2010=Not rec.),Office 2010+ACC.2013 ,Symbian C++, AC.2013.SystemResource.GetCurrentFreeSize=?

    Thursday, February 8, 2018 4:09 PM
  • Hello, try to use early binding using Outlook reference:

    Dim objOL as Outlook.Application Set objOL = New Outlook.Application

    More here: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/automating-outlook-from-a-visual-basic-application?f=255&MSPPError=-2147217396

    Wednesday, February 14, 2018 3:53 PM