PDA

View Full Version : Save document as PDF



Bernadette
06-25-2013, 08:23 AM
The following macro prompts to save the document and then sends it to Outlook. It works well but I was wondering if there is a way to save the document as a PDF? Any help is much appreciated! I am using Word 2007.

Public Sub commandbutton1_click()
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = "Visitor Authorization"
.body = "Please find attached the authorization form." & vbCrLf & _
"" & vbCrLf & _
"Thank you," & vbCrLf & _
"" & vbCrLf & _
"Name"
.To = "name@address.ca"
.CC = "name@address.ca"
' .Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow
.importance = 2 'importance is high
.Attachments.Add Doc.FullName
.Display
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub

Doug Robbins
06-29-2013, 02:29 AM
Take a look at the code in my MergeTools Add-in that you can download from

https://skydrive.live.com/?cid=5aedcb43615e886b#!/?cid=5AEDCB43615E886B!cid=5AEDCB43615E886B&id=5AEDCB43615E886B%21566 (https://skydrive.live.com/?cid=5aedcb43615e886b#!/?cid=5AEDCB43615E886B!cid=5AEDCB43615E886B&id=5AEDCB43615E886B%21566)

In the Merge with Attachments, there is code that creates a pdf version of the merge document and attachs it to an email message.

Bernadette
06-29-2013, 06:57 AM
Hello Doug,

Thank you for your reply. I went to your link and the only thing I could download was the PDF. If possible I would like to see the macro code.

Thanks, Bernie

fumei
06-29-2013, 12:58 PM
Bernadette can you see the files Merge Tools - there is a dotm (2007 or 2020) and a dot (for 2003). The code is in there.

Doug Robbins
06-29-2013, 02:05 PM
Hello Doug,

Thank you for your reply. I went to your link and the only thing I could download was the PDF. If possible I would like to see the macro code.

Thanks, Bernie

You need to download the MergeTools - 20130627.dotm file that is on that page.