ArrayON_56
New Member
- Joined
- Jul 9, 2021
- Messages
- 9
- Office Version
- 2019
- Platform
- Windows
I would like to create a VBA script in excel that analyzes Subject of currently viewed mail in Outlook, parse it and put some info from it to excel cell.
However when I want to read the subject from Outlook by Outlook.Application.ActiveInspector, it gives me runtime error 91 to line "Set Inspector = OutlookApp.ActiveInspector" - Object variable or With block variable not set.
But I have initialised the variable it and I am trying to set it to be ActiveInspector of Outlook.
Here is my code:
Sub TestFunction()
Dim OutlookApp As Outlook.Application
Dim Inspector As Outlook.Inspector 'I initialise the variable here
Dim Item As Outlook.Inspector
Set Inspector = OutlookApp.ActiveInspector 'This is the error 91 line
Set Item = Inspector.CurrentItem
End Sub
What am I doing wrong?
Thanks in advance
However when I want to read the subject from Outlook by Outlook.Application.ActiveInspector, it gives me runtime error 91 to line "Set Inspector = OutlookApp.ActiveInspector" - Object variable or With block variable not set.
But I have initialised the variable it and I am trying to set it to be ActiveInspector of Outlook.
Here is my code:
Sub TestFunction()
Dim OutlookApp As Outlook.Application
Dim Inspector As Outlook.Inspector 'I initialise the variable here
Dim Item As Outlook.Inspector
Set Inspector = OutlookApp.ActiveInspector 'This is the error 91 line
Set Item = Inspector.CurrentItem
End Sub
What am I doing wrong?
Thanks in advance