Consulting

Results 1 to 9 of 9

Thread: Attaching embedded ppt object to the outlook mail using VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Attaching embedded ppt object to the outlook mail using VBA

    Hello Everyone,


    I have been hustling to do the following:

    1. Copy all slides from current presentation which has macros (with .pptm extension) into an embedded/hidden/OLE object with .pptx extension.
    2. Attach this pptx to outlook mail

    The reason to do this is to avoid virus while attaching macro contained PowerPoint. Please help, that will be like ray of hope. Following is drafts of code I am working on;

    They are two approaches which came into my mind.
    1. One is using similar thread : http://www.vbaexpress.com/forum/show...ook-attachment

    Code:

    Dim OutlookApp As Object
    Dim OutlookMessage As Object
    Dim otemp As presentation
    Dim opres As presentation
    Dim strName As String
    Dim strSubject As String
    
    
    
    
    Dim L As Long
    
    
    Set opres = ActivePresentation
    
    
    strSubject = opres.name
    
    
    ' make a copy
    opres.SaveCopyAs Environ("TEMP") & "" & strName & ".pptx"
    'open the copy
    Set otemp = Presentations.Open(Environ("TEMP") & "" & strName & ".pptx")
    otemp.Save
    otemp.Close
    On Error Resume Next
    Set OutlookApp = GetObject(Class:="Outlook.Application")
    Err.Clear
    If OutlookApp Is Nothing Then Set OutlookApp = CreateObject(Class:="Outlook.Application")
    On Error GoTo 0
    Set OutlookMessage = OutlookApp.CreateItem(0)
    
    
    On Error Resume Next
    With OutlookMessage
    .To = "username.gmail.com" 'Insert email address here!
    .CC = ""
    .Subject = strSubject
    .body = "Slides are attached"
    .Attachments.Add Environ("TEMP") & "" & strName & ".pptx"
    .Display
    End With
    End Sub

    2. Copying all slides from pptm file into the embedded and then attaching this pptx file to outlook (just an idea)

    PPTMainPres is the presentation with macros 
    PPTPres is the OLE hidden/embedded object
    
     Set PPTPres = oOleObj ' embedded presentation or object
         PPTMainPres.Slides.Range.Copy
         PPTPres.Slides.Paste
    ---------------------------
    
     .Attachments.Add PPTPres  ".pptx"
    Last edited by Paul_Hossler; 10-17-2019 at 12:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •