I have encountered issues where an Outlook rule that is set to run a VBA script would sporadically run into errors. I know the script works because I've tested the script as a Public Sub and I've tested my rule. However, I need my rule to run successfully 100% of the time.
I don't know why my rule encounters errors since there is no error description for Outlook rule failures. So for a workaround, I decided to get my Outlook script running by calling it from Excel. However, I can't get the right connections yet. Can someone please help me run my Outlook VBA script 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
Below is the 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
Answer
After further research, I believe that the VBA coding compatibility between Outlook and Excel don't have developer functionality. However, I was able to complete my task by taking my VBA macro from Outlook and inserting into an Excel book.
Essentially, I removed any VBA coding from Outlook so everything was able to be completed using Excel. If anyone is interested in the codes please let me know.
No comments:
Post a Comment