Closed Thread
Results 1 to 1 of 1

Email a converted worksheet as pdf to addresses in a range of cells

Hybrid View

  1. #1
    Registered User
    Join Date
    02-09-2011
    Location
    ft. lauderdale, fl
    MS-Off Ver
    Excel 2010
    Posts
    16

    Email a converted worksheet as pdf to addresses in a range of cells

    I have found and copied the vba code to convert and email a worksheet as a pdf file but want to to send the file to email addresses within a range of cells within that worksheet. for example
    A1 [email protected]
    A2 [email protected]
    A3 [email protected]

    I currently use this to send the worksheet without converting to pdf from Ron De Bruin's website.

    Dim rng As Range
        Dim Arr() As String
        Dim N As Integer
        Dim cell As Range
    
        Set rng = ThisWorkbook.Sheets("Letter Template").Range("b13:B15")
        ReDim Preserve Arr(1 To rng.Cells.Count)
        N = 0
        For Each cell In rng
            If cell.Value Like "?*@?*.?*" Then
                N = N + 1
                Arr(N) = cell.Value
            End If
        Next cell
        ReDim Preserve Arr(1 To N)
        
        .SendMail Arr,  "Margin Report"
    this is the part of the code to send excel worksheet as pdf file.

    FileName = RDB_Create_PDF(ActiveSheet, "", True, False)
    
        If FileName <> "" Then
            RDB_Mail_PDF_Outlook FileName, "[email protected]", "This is the subject", _
                                 "See the attached PDF file with the last figures" _
                               & vbNewLine & vbNewLine & "Regards Jane Doe", False
        Else
            MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
                   "Microsoft Add-in is not installed" & vbNewLine & _
                   "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
                   "The path to Save the file in arg 2 is not correct" & vbNewLine & _
                   "You didn't want to overwrite the existing PDF if it exist"
        End If
    End Sub
    hope this makes sense.
    Last edited by Paul; 02-23-2011 at 01:15 PM. Reason: Added code tags; User created new thread, so this one is being closed.

Closed Thread

Thread Information

Users Browsing this Thread

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

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