locked
Excel Outlook Error RRS feed

  • Question

  • I am trying to fix a Macro that saves a report and then generates an email with that report...

    this is the error Im getting

    Sub Daily_PO_Receipts()
    '
    ' Daily_PO_Receipts Macro
    '

    '
        ActiveWorkbook.SaveAs "(I had the attachment here but took it off for this)"
       
        Application.Run "Mail_Outlook_With_Signature_Html_5()"  <------- THIS IS THE ERROR
        End Sub

    Sub Mail_Outlook_With_Signature_Html_5()
    'Working in Office 2000-2013
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String

        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)

        strbody = "Hello all, I have attached today's Daily PO Receipts report.  Have a great evening."

        On Error Resume Next

        With OutMail
            .Display
            .To = "I deleted the emails for privacy"
            .Subject = "Daily PO Receipts" & Format$(Date, " mm-dd-yyyy")
            .HTMLBody = strbody & "<br>" & .HTMLBody
            .Attachments.Add (I had the attachment here but took it off for this)

           
        End With

        On Error GoTo 0
        Set OutMail = Nothing
        Set OutApp = Nothing
      End Sub

    Tuesday, October 18, 2016 1:01 PM

All replies

  • Hi Cox,

    What error do you get? I made a test with below code, it works at my side. Could you share us your complete code and your Office version?

    Sub Daily_PO_Receipts()
         ActiveWorkbook.SaveAs "D:\test.xlsm" ', XlFileFormat.xlOpenXMLWorkbookMacroEnabled
         Application.Run "Mail_Outlook_With_Signature_Html_5()"
         End Sub
    
    Sub Mail_Outlook_With_Signature_Html_5()
     'Working in Office 2000-2013
         Dim OutApp As Object
         Dim OutMail As Object
         Dim strbody As String
        Set OutApp = CreateObject("Outlook.Application")
         Set OutMail = OutApp.CreateItem(0)
        strbody = "Hello all, I have attached today's Daily PO Receipts report.  Have a great evening."
        On Error Resume Next
        With OutMail
             .Display
             .To = "I deleted the emails for privacy"
             .Subject = "Daily PO Receipts" & Format$(Date, " mm-dd-yyyy")
             .HTMLBody = strbody & "<br>" & .HTMLBody
             .Attachments.Add ("D:\test.xlsm")
         End With
        On Error GoTo 0
         Set OutMail = Nothing
         Set OutApp = Nothing
       End Sub
    

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, October 19, 2016 8:28 AM