+ Reply to Thread
Results 1 to 2 of 2

Dialogue Box for Attachment

Hybrid View

abac Dialogue Box for Attachment 02-01-2020, 09:19 AM
Pepe Le Mokko Re: Dialogue Box for... 02-01-2020, 09:38 AM
  1. #1
    Registered User
    Join Date
    01-18-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    87

    Dialogue Box for Attachment

    Hi gurus,

    how can i get dialogue box in VBA for attachments before sending email ?

    I'm currently using the following code and it creates PDF file which is fine but I also want some other files to attach with the email, however I'd like it to select it manually rather than defining the path. Please can someone guide me on this.

    Many thanks,
    Private Sub CommandButton1_Click()
    
      Dim IsCreated As Boolean
      Dim i As Long
      Dim PdfFile As String, Title As String
      Dim OutlApp As Object
        
        ' Define PDF filename
      PdfFile = ActiveWorkbook.FullName
      i = InStrRev(PdfFile, ".")
      If i > 1 Then PdfFile = Left(PdfFile, i - 1)
      PdfFile = PdfFile & "_" & ActiveSheet.Name & ".pdf"
     
      ' Export activesheet as PDF
      With ActiveSheet
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
      End With
     
      ' Use already open Outlook if possible
      On Error Resume Next
      Set OutlApp = GetObject("Outlook.Application")
      If Err Then
        Set OutlApp = CreateObject("Outlook.Application")
        IsCreated = True
      End If
      OutlApp.Visible = True
      On Error GoTo 0
    
     
      ' Prepare e-mail with PDF attachment
       With OutlApp.CreateItem(0)
       
       CarryOn = MsgBox("ARE YOU SURE?", vbYesNo, "TEST")
    If CarryOn = vbYes Then
       
        ' Prepare e-mail
        .Subject = "XYZ"
        .To = "XYZ@XYZ.COM"
           .Body = "Hi," & vbLf & vbLf _
              & "XYZ." & vbLf & vbLf _
              & "XYZ," & vbLf _
              & Application.UserName & vbLf & vbLf
        .Attachments.Add PdfFile
       
           
        ' Try to send
        On Error Resume Next
        .send
        Application.Visible = True
        If Err Then
          MsgBox "E-mail was not sent", vbExclamation
        Else
          MsgBox "E-mail successfully sent", vbInformation
        End If
        On Error GoTo 0
       End If
      End With
     
     
      ' Delete PDF file
      Kill PdfFile
    
     
      
      ' Release the memory of object variable
      Set OutlApp = Nothing
     
     
    End Sub

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,631

    Re: Dialogue Box for Attachment

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    Despite three warnings about not following our forum rules about cross posting ( and one about another infraction), I am withdrawing your posting privileges for seven days

    No help to be provided until the banning period expires

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Dialogue Box VBA
    By KG23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2014, 01:27 PM
  2. Attachment manipulation based on string in attachment
    By fterveen in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2012, 08:40 AM
  3. Pop up dialogue box
    By TG77 in forum Excel General
    Replies: 1
    Last Post: 06-28-2010, 11:15 AM
  4. Dialogue Box?
    By sgilleland in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-22-2007, 04:39 AM
  5. dialogue pop up
    By Micayla Bergen in forum Excel General
    Replies: 5
    Last Post: 06-23-2006, 05:50 PM
  6. pop up dialogue box
    By Micayla Bergen in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-22-2006, 09:40 PM
  7. pop up dialogue
    By Micayla Bergen in forum Excel General
    Replies: 0
    Last Post: 06-22-2006, 09:25 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1