I have an Outlook rule, to run a VBA script, that sporadically runs into errors. I know the script works because I've tested the script as a Public Sub.
I don't know why my rule encounters errors since there is no error description for Outlook rule failures. For a workaround, I decided to get my Outlook script running by calling it from Excel.
The error I receive is:
Run-time error '438'. Object doesn't support this property or method.
The references I have on Excel are:
- Visual Basic For Applications
- Microsoft Excel 16.0 Object Library
- OLE Automation
- Microsoft Office 16.0 Object Library
- Microsoft Outlook 16.0 Object Library
Outlook references are:
- Visual Basic For Applications
- Microsoft Outlook 16.0 Object Library
- OLE Automation
- Microsoft Office 16.0 Object Library
- Microsoft Form 2.0 Object Library
- Microsoft Excel 16.0 Object Library
Code for Excel:
Public Sub testexcel()
Dim o As Outlook.Application
On Error Resume Next
Set o = GetObject("", "Outlook.Application")
Err.Clear: On error GoTo 0
If o Is Nothing then
Set o = CreateObject("Outlook.Application")
End If
With o
.Session.Logon
.Run "testoutlook" ' <--------- Error Line
End With
o.Close
o.Quit
Set o = Nothing
End Sub
Outlook sample code:
Public Sub testoutlook()
Call MsgBox("HellO")
End Sub