excel to pdf conversion and sending email from outlook

murali_urfrnd

New Member
Joined
Dec 17, 2015
Messages
2
Hello! Everyone
I am new to VBA. My issue might sound very simple but I am stuck with it.
I have my data in excel. Sheet one has email ids and names that has to be given to the PDF.
Sheet two has a certificate and the cell range of it is A1 to P36.
I need a macro to convert the cell range in sheet two to pdf, give the pdf name as mentioned in D13 of sheet one, save it to a folder on C:\ drive, and then send it to the email id mentioned in C13 of sheet one.

Need help on this. Any suggestions would be appreciated.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hello! Guys
I found the coding for it online. Did a little bit of modification and it works now.

Sub RDB_Selection_Range_To_PDF_And_Create_Mail()
Dim FileName As String


If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "There is more then one sheet selected," & vbNewLine & _
"ungroup the sheets and try the macro again"
Else
'Call the function with the correct arguments
'For a fixed range use this line
FileName = RDB_Create_PDF(Source:=Sheets("Sheet2").Range("A2:P37"), _
FixedFilePathName:="C:\certificate\" & Range("D13") & ".pdf", _
OverwriteIfFileExist:=True, _
OpenPDFAfterPublish:=False)


'For the selection use Selection in the Source argument
'FileName = RDB_Create_PDF(Source:=Selection)


'For a fixed file name use this in the FixedFilePathName argument
'FixedFilePathName:="C:\Users\Ron\Test\YourPdfFile.pdf"


RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
StrTo:=Range("B13"), _
StrCC:=Range("C13") & "; " & Range("B13"), _
StrBCC:="", _
StrSubject:="Certificate", _
Signature:=True, _
Send:=False, _
StrBody:="<H3><B>Dear </B></H3><br>" & _
"<body>See the attached PDF file for your certificate." & _
"<br><br>Have a wonderful day ahead." & _
"<br><br>Regards," & _
"<br>CE Team</body>"
End If
End Sub

Now I want to password protect the PDF so that the user can't modify or copy it. The user should only be able to view and print it.
Can anyone help me with this?
Any sort of help would be appreciated.
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top