none
Run-time error 438: OBJECT DOESN'T SUPPORT THIS PROPERTY OR METHOD

    Question

  • Good day

    i seem to get a run-time error 438: Object doesn't support this property or Method every time i try running my macro to automatically attach a PDF file called "Statement.xlsm"

    Please assist, i am new at this VBA 

    here is my code:

    Dim objOutlook As Object
        Dim objNameSpace As Object
        Dim objInbox As Object
        Dim objMailItem As Object
        Set objOutlook = CreateObject("Outlook.Application")
        Set objNameSpace = objOutlook.GetNamespace("MAPI")
        Set objInbox = objNameSpace.Folders(1)
        Set objMailItem = objOutlook.CreateItem(0)
            'Declare a String variable for the recipient list, and an Integer variable
            'for the count of cells in column A that contain email addresses.
            Dim strTo As String
            Dim i As Integer
            strTo = ""
            i = 1


        'Loop through the recipient email addresses to build a continuous string that separates recipient addresses by a semicolon and a space.
        With Worksheets("Statement") 'change sheet name where list is kept.
        Do
        strTo = strTo & .Cells(i, 25).Value & "; "
        i = i + 1
        Loop Until IsEmpty(.Cells(i, 25))
        End With
        'Remove the last two characters from the recipient string, which are
        'an unnedded semicolon and space.
        strTo = Mid(strTo, 1, Len(strTo) - 2)
        'Display the email message with the attached active workbook.
        With objMailItem
        .To = strTo
        .CC = "Eutychus@gcis.gov.za"
        .Subject = "Media buying Statement"
        .Body = _
        "Hello everyone," & Chr(10) & Chr(10) & _
        "Here's an example for attaching the active workbook" & Chr(10) & _
        "to an email with multiple recipients."

        Dim Attachment1 As String

        Attachment1 = "http://ecms.gcis.gov.za/sites/docs/fin_mngmnt/47 Systems/4-7-3 Media Buying System/4-7-3-1 Media Buying Statements/Statement.xlsm.pdf"

         .addAttachments Attachment1 '(this is were is says i must debug) 

        .Display 'Change to Send if you want to just send it.

        End With
        'Release object variables from system memory.
        Set objOutlook = Nothing
        Set objNameSpace = Nothing
        Set objInbox = Nothing
        Set objMailItem = Nothing

    Thank you in advance

    Wednesday, January 21, 2015 11:55 AM

Answers

  • The correct would be:

      .Attachments.Add Attachment1

    However, I couldn't get the file in the URL indicated by Attachment1, because the URL http://ecms.gcis.gov.za/sites/docs/fin_mngmnt/47 Systems/4-7-3 Media Buying System/4-7-3-1 Media Buying Statements/Statement.xlsm.pdf doesn't exist. Are you sure it is correct?


    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Wednesday, January 21, 2015 12:09 PM

All replies

  • Good day

    i seem to get a run-time error 438: Object doesn't support this property or Method every time i try running my macro to automatically attach a PDF file called "Statement.xlsm"

    Please assist, i am new at this VBA 

    here is my code:

    Dim objOutlook As Object
        Dim objNameSpace As Object
        Dim objInbox As Object
        Dim objMailItem As Object
        Set objOutlook = CreateObject("Outlook.Application")
        Set objNameSpace = objOutlook.GetNamespace("MAPI")
        Set objInbox = objNameSpace.Folders(1)
        Set objMailItem = objOutlook.CreateItem(0)
            'Declare a String variable for the recipient list, and an Integer variable
            'for the count of cells in column A that contain email addresses.
            Dim strTo As String
            Dim i As Integer
            strTo = ""
            i = 1


        'Loop through the recipient email addresses to build a continuous string that separates recipient addresses by a semicolon and a space.
        With Worksheets("Statement") 'change sheet name where list is kept.
        Do
        strTo = strTo & .Cells(i, 25).Value & "; "
        i = i + 1
        Loop Until IsEmpty(.Cells(i, 25))
        End With
        'Remove the last two characters from the recipient string, which are
        'an unnedded semicolon and space.
        strTo = Mid(strTo, 1, Len(strTo) - 2)
        'Display the email message with the attached active workbook.
        With objMailItem
        .To = strTo
        .CC = "Eutychus@gcis.gov.za"
        .Subject = "Media buying Statement"
        .Body = _
        "Hello everyone," & Chr(10) & Chr(10) & _
        "Here's an example for attaching the active workbook" & Chr(10) & _
        "to an email with multiple recipients."

        Dim Attachment1 As String

        Attachment1 = "http://ecms.gcis.gov.za/sites/docs/fin_mngmnt/47 Systems/4-7-3 Media Buying System/4-7-3-1 Media Buying Statements/Statement.xlsm.pdf"

         .addAttachments Attachment1 '(this is were is says i must debug) 

        .Display 'Change to Send if you want to just send it.

        End With
        'Release object variables from system memory.
        Set objOutlook = Nothing
        Set objNameSpace = Nothing
        Set objInbox = Nothing
        Set objMailItem = Nothing

    Thank you in advance

                           
    Tuesday, January 20, 2015 3:25 PM
  • Instead of .addAttachments use .Attachments.Add:

            .Attachments.Add Attachment1


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, January 20, 2015 3:34 PM
  • By the way, you posted this in the Access for Developers forum, but the code suggests you're running it from Excel...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, January 20, 2015 3:36 PM
  • Oops....

    thanks for your response...

    Wednesday, January 21, 2015 11:57 AM
  • The correct would be:

      .Attachments.Add Attachment1

    However, I couldn't get the file in the URL indicated by Attachment1, because the URL http://ecms.gcis.gov.za/sites/docs/fin_mngmnt/47 Systems/4-7-3 Media Buying System/4-7-3-1 Media Buying Statements/Statement.xlsm.pdf doesn't exist. Are you sure it is correct?


    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Wednesday, January 21, 2015 12:09 PM
  • i am still getting an that error. here is the top part of my code:

                            


    Sub EmailAttachmentRecipients()
    'Declare and establish the Object variables for Outlook.

        Dim ws3 As Workbook

        Set ws3 = Workbooks("Statement.xlsm")

        ws3.Sheets("Consolidated").Visible = False
        ws3.Sheets("Schedule2").Visible = False
        ws3.Sheets("0-9File").Visible = False
        ws3.Sheets("Campaign").Visible = False
        ws3.Sheets("Database").Visible = False


        Dim sFileName As String
        sFileName = ActiveWorkbook.FullName & ".pdf"
        ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFileName, Quality:=xlQualityStandard, openAfterPublish:=False

        ws3.Sheets("Consolidated").Visible = True
        ws3.Sheets("Schedule2").Visible = True
        ws3.Sheets("0-9File").Visible = True
        ws3.Sheets("Campaign").Visible = True
        ws3.Sheets("Database").Visible = True

    • Proposed as answer by Peter N Roth Wednesday, January 21, 2015 10:08 PM
    • Unproposed as answer by Peter N Roth Wednesday, January 21, 2015 10:08 PM
    Wednesday, January 21, 2015 12:17 PM
  • Whoooooopy!

    It works... Thanks very much Felipe. by the way that http>>>>>> is the file path on sharepoint

    thanks again

    Wednesday, January 21, 2015 12:22 PM
  • Hi LeSebati,

    Whoooooopy!

    It works... Thanks very much Felipe. by the way that http>>>>>> is the file path on sharepoint

    thanks again

    The site is not accessable. Where is the site from? It is hard to say whether the site is an SharePoint site. I suggest that you check it with the owner of this site.

    Regards & Fei


    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.

    Thursday, January 29, 2015 10:47 AM
    Moderator
  • @Fei,

    You might have missed, but the link is to an internal site, of his company, and he already solved his issue.


    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Thursday, January 29, 2015 5:10 PM
  • Hi Felipe Costa Gualberto,

    Yes, you are correct. Understood it now:)

    Regards & Fei


    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.

    Monday, February 02, 2015 8:52 AM
    Moderator