none
How can I run a outlook macro in excel? RRS feed

  • Question

  • Is it possible to run a macro from outlook in excel? I want to run a macro in excel to call a function in outlook. 

    Any suggestions?

    Wednesday, October 31, 2018 1:55 PM

All replies

  • Hi yoona530,

    I'm not sure that what kind of feature you want. However, you can refer to the following link:

    Mail the whole workbook

    Sub Mail_workbook_Outlook_1()
    'Working in Excel 2000-2016
    'This example send the last saved version of the Activeworkbook
    'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
        Dim OutApp As Object
        Dim OutMail As Object
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
        With OutMail
            .to = "ron@debruin.nl"
            .CC = ""
            .BCC = ""
            .Subject = "This is the Subject line"
            .Body = "Hi there"
            .Attachments.Add ActiveWorkbook.FullName
            'You can add other files also like this
            '.Attachments.Add ("C:\test.txt")
            .Send   'or use .Display
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub

    Using the CreateObject("Outlook.Application") object to implement your needs.

    Regards,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, November 1, 2018 8:56 AM
    Moderator