Results 1 to 2 of 2
  1. #1
    annmv888 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    15

    Method or data member not found

    I am using MS Access 2010 and new to VBA. I found the code below to forward an Outlook email with attachments. I receive the "method or data member not found" on the following line:
    Set myToBeForwarded = Application.ActiveExplorer.Selection(1)
    Specifically the .ActiveExplorer part.


    Thanks for any help in advance.
    Complete Code Below:
    Code:
    Sub ForwardEmail()
    Dim myItem As Outlook.MailItem
    Dim myToBeForwarded As Outlook.MailItem
    Dim strRecipient As String
    Dim strStatementMonth As String
    Dim strThroughDate As String
    Dim strHTML As String
    Dim fs As Object
    Dim Atmt As Attachment
    Dim FileName As String
    Dim Inbox As MAPIFolder
    Dim MyItems As Items
    Dim objOutlookAttach As Outlook.Attachment
    Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set MyItems = Inbox.Items
    Set myToBeForwarded = Application.ActiveExplorer.Selection(1)
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set myItem = Application.CreateItemFromTemplate("C:\Users\username\AppData\Roaming\Microsoft\Templates\Statement.oft")
    strHTML = myItem.HTMLBody
    strLastName = InputBox("Recipients Last Name?")
    strFirstName = InputBox("Recipients First Name?")
    strPrefix = InputBox("Recipients Prefix (ex. Mr., Ms., Dr.)?")
    strMatterID = InputBox("Matter Number?")
    strStatementMonth = InputBox("What is the statement date?")
    strThroughDate = InputBox("Services rendered through what date?")
    myItem.HTMLBody = Replace(myItem.HTMLBody, "%STATEMENTMONTH%", strStatementMonth)
    myItem.HTMLBody = Replace(myItem.HTMLBody, "%THROUGHDATE%", strThroughDate)
    myItem.HTMLBody = Replace(myItem.HTMLBody, "%RECIPIENT%", strRecipient)
    myItem.HTMLBody = Replace(myItem.HTMLBody, "%PREFIX%", strPrefix)
    myItem.HTMLBody = Replace(myItem.HTMLBody, "%LASTNAME%", strLastName)
    myItem.Subject = Replace(myItem.Subject, "%LASTNAME%", strLastName)
    myItem.Subject = Replace(myItem.Subject, "%FIRSTNAME%", strFirstName)
    myItem.Subject = Replace(myItem.Subject, "%MATTERID%", strMatterID)
     
    For Each Atmt In myToBeForwarded.Attachments
        'save it in C:\temp
        FileName = "C:\TempPDF\" & Atmt.FileName
        Atmt.SaveAsFile FileName
        'now attach it to the new message
        Set objOutlookAttach = myItem.Attachments.Add(FileName)
        fs.deletefile FileName, True
    Next
     
    myItem.Display
    End Sub

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I believe
    Application.ActiveExplorer is a member of Outlook.Explorer. You have it dim'd as Outlook.MailItem
    If that's not the issue, I'm afraid I can't shed more light on this subject.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Me.DOExp - Method or data member not found
    By GraeagleBill in forum Forms
    Replies: 4
    Last Post: 02-12-2016, 07:16 PM
  2. Method or data member not found
    By hendrikbez in forum Access
    Replies: 2
    Last Post: 11-21-2014, 10:52 AM
  3. Method or Data Member not found
    By johnnyBQue in forum Programming
    Replies: 4
    Last Post: 11-03-2014, 07:15 AM
  4. Method or Data member not found error
    By junwatts in forum Access
    Replies: 1
    Last Post: 09-27-2013, 08:49 AM
  5. Method or data member not found
    By papa yaw in forum Programming
    Replies: 5
    Last Post: 12-17-2012, 02:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums