Error: class does not support Automation or does not support expected interface

antokout

New Member
Joined
Sep 20, 2018
Messages
28
Guys I need help. I run a code on VBA in my work , and on some pc i could run it and on other i couldnt. I read some answers for that error and they said that maybe its service pack for windows i check it and it wasnt . Can someone help me?



Thank you
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Maybe, if you post the code that causes the error.
Code:
Sub CountInboxSubjects()

    Dim olApp As Outlook.Application
    Dim olNs As Outlook.Namespace
    Dim olFldr As Outlook.MAPIFolder
    Dim olMailItem As Outlook.MailItem
    Dim propertyAccessor As Outlook.propertyAccessor
    Dim olItem As Object
    Dim dic As Dictionary
    Dim i As Long
    Dim Subject As String
    
    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
    Set dic = New Dictionary
    
    For Each olItem In olFldr.Items
        If olItem.Class = olMail Then
            Set propertyAccessor = olItem.propertyAccessor
            Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E")
            If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1
        End If
    Next olItem

    With ActiveSheet
        .Columns("A:B").Clear
        .Range("A1:B1").Value = Array("Count", "Subject")
        For i = 0 To dic.Count - 1
            .Cells(i + 2, "A") = dic.Items()(i)
            .Cells(i + 2, "B") = dic.Keys()(i)
        Next
    End With
End Sub
 
Last edited by a moderator:
Upvote 0
Which line causes the error and do all the computers have the exact same version of Office and Windows? (If you're actually retrieving the Subject, you don't need a PropertyAccessor as Subject is an exposed property of a MailItem.)
 
Last edited:
Upvote 0
Which line causes the error and do all the computers have the exact same version of Office and Windows? (If you're actually retrieving the Subject, you don't need a PropertyAccessor as Subject is an exposed property of a MailItem.)

All computers have the same version office and windows. Line of propertyAccessor causes the error and how i could do this subject counting without propertyaccessor?
 
Upvote 0
Just replace this:

Code:
Set propertyAccessor = olItem.propertyAccessor
            Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E")

with this:

Code:
            Subject = olItem.Subject
 
Upvote 0
Yeah thanks mate... i quess propertyaccessor was the problem do you know how i could put and date on this code?
 
Upvote 0

Forum statistics

Threads
1,214,543
Messages
6,120,123
Members
448,947
Latest member
test111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top