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
 
Your code will need a rewrite then. I'll have a look when I have time.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Something like this should work:

Code:
Sub CountInboxSubjects()

    Dim olApp As Outlook.Application
    Dim olNs As Outlook.Namespace
    Dim olFldr As Outlook.MAPIFolder
    Dim propertyAccessor As Outlook.propertyAccessor
    Dim olItem As Object
    Dim dic As Dictionary
    Dim i As Long
    Dim Subject As String
    Dim data
    
    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
            Subject = olItem.Subject
            If dic.Exists(Subject) Then
                data = Split(dic(Subject), "|")
                data(0) = data(0) + 1
                If olItem.ReceivedTime > CDate(data(1)) Then data(1) = olItem.ReceivedTime
                dic(Subject) = Join(data, "|")
            Else
                dic(Subject) = 1 & "|" & olItem.ReceivedTime
            End If
        End If
    Next olItem

    With ActiveSheet
        .Columns("A:C").Clear
        .Range("A1:C1").Value = Array("Count", "Subject", "Date")
        For i = 0 To dic.Count - 1
            data = Split(dic.Items()(i), "|")
            .Cells(i + 2, "A") = data(0)
            .Cells(i + 2, "B") = dic.Keys()(i)
            .Cells(i + 2, "C") = CDate(data(1))
        Next
    End With
End Sub
 
Upvote 0
Yeah thanks a lot. Sorry for bothering you but do you know how can i do exactly this code for specific subfolders thats inside in my inbox? i should use different modules with the same code but different olFolderInbox?
 
Upvote 0
You could amend the code to take either a folder name, or an actual MAPIFolder object, as an argument and then just call it from several different macros using the folder you want.
 
Upvote 0
You could amend the code to take either a folder name, or an actual MAPIFolder object, as an argument and then just call it from several different macros using the folder you want.

and this could work if i wanted to create different worksheets for each subfolder of my inbox?
 
Upvote 0
You'd need to amend it to either create a new sheet each time, or have your other macros create a new sheet and then call that code.
 
Upvote 0

Forum statistics

Threads
1,224,754
Messages
6,180,749
Members
452,996
Latest member
nelsonsix66

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