title: How to use VBA in PowerPoint to attach an OLE Object to an Outlook email
body: <p>I have an embedded OLE object in a PowerPoint slide and I am trying to make a macro that will open Outlook with the OLE object automatically added as an attachment.  </p>
  
  <p>The OLE object (a pdf) was inserted into the slide using the normal insert>object>create from file>display as icon method, so it appears as a little pdf icon on the slide from which I would like to launch the macro.</p>
  
  <p>I have figured out the basic VBA for opening Outlook, displaying a new message and all of that, but I can't quite get the attachment to work.  Here is the code I'm working with:</p>
  
  <pre><code>Sub SendEmailwithAttachment()
  
  Dim OutApp As Object
  Dim OutMail As Object
  Dim strbody As String
  
  Set OutApp = CreateObject("Outlook.Application")
  Set OutMail = OutApp.CreateItem(0)
  
  strbody = "Dear []:&lt;br&gt;" &amp; _
            "&lt;br&gt;&lt;br&gt;Attached is .&lt;br&gt;" &amp; _
            "&lt;br&gt;&lt;br&gt;Let me know if you have any questions.&lt;br&gt;" &amp; _
            "&lt;br&gt;&lt;br&gt;Thank you,"
  
  On Error Resume Next
  
  With OutMail
      .To = ""
      .CC = ""
      .BCC = ""
      .Subject = ""
      .HTMLBody = strbody 
      .Attachments.Add (ActivePresentation.Slides(2).Shapes("Attachment"))
      .Display
  End With
  On Error GoTo 0
  
  Set OutMail = Nothing
  Set OutApp = Nothing
  End Sub
  </code></pre>
  
  <p>I had previously used the exact same code to attach a file through a file path, and everything worked perfectly.  But now I need to embed the file in the PowerPoint instead of merely directing the code to attach from the file path.  </p>
  
  <p>Both PowerPoint and Outlook are 2010.  </p>
  
  <p>Any help would be greatly appreciated.</p>