(Solved) – How to Convert my VBA process to run in MAC?

(solved)-–-how-to-convert-my-vba-process-to-run-in-mac?

I have an excel macro that works perfect in windows (email text extraction), but when I run it in my mac it gives me the error missing the library Microsoft Outlook 16.0 Object Library.

I was thinking in late binding (I tried but I wasn’t able to fix it)

Can you pls help me to fix my code in order to run it in my mac? thanks in advance.

Code Below:

Sub DetailExtraction() 'MacVersion
    On Error GoTo ErrHandler

    Application.ScreenUpdating = False
    ' SET Outlook APPLICATION OBJECT.
    Dim objOutlook As Object
    Set objOutlook = CreateObject("Outlook.Application")

    ' CREATE AND SET A NameSpace OBJECT.
    Dim objNSpace As Object
    ' THE GetNameSpace() METHOD WILL REPRESENT A SPECIFIED NAMESPACE.
    Set objNSpace = objOutlook.GetNamespace("MAPI")

    ' CREATE A FOLDER OBJECT.
    Dim myFolder As Object
    Set myFolder = objNSpace.GetDefaultFolder(olFolderInbox)

    Dim Item As Object
    Dim iRows, iCols As Integer
    iRows = 2

    ' LOOP THROUGH EACH ITEMS IN THE FOLDER.
    'For Each objItem In myFolder.Items
    ' LOOP THROUGH EACH ITEMS IN THE SELECTION.
    For Each objItem In ActiveExplorer.Selection

        If objItem.Class = olMail Then

            Dim objMail As Outlook.MailItem ' PROBLEM IS IN THIS LINE
            Set objMail = objItem

            Cells(iRows, 1) = objMail.SenderEmailAddress
            Cells(iRows, 2) = objMail.To
            Cells(iRows, 3) = objMail.Subject
            Cells(iRows, 4) = objMail.ReceivedTime
            Cells(iRows, 6) = objMail.Body
            Cells(iRows, 6).WrapText = False
            'MsgBox Prompt:=objMail.Body
       End If

       'WRAP UP FILE OFF
      ' Cells*i.WrapText = False
        ' SHOW OTHER PROPERTIES, IF YOU WISH.
        'Cells(iRows, 6) = objMail.Body
        'Cells(iRows, 5) = objMail.CC
        'Cells(iRows, 6) = objMail.BCC
        'Cells(iRows, 4) = objMail.Recipients(1)

        iRows = iRows   1
    Next
    Set objMail = Nothing

    ' RELEASE.
    Set objOutlook = Nothing
    Set objNSpace = Nothing
    Set myFolder = Nothing
ErrHandler:
    Debug.Print Err.Description
Application.ScreenUpdating = True
MsgBox "Environments Details Extracted from the Selected Emails (" & iRows - 2 & ")"
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *