![]() |
#1
|
|||
|
|||
![]()
Below is the code that I am working with. The code works fine. The macro will save the file and prepare an email to be send with an attachment in MS-Word format.
I would like to revise the code so that after the user clicks a button called 'convert', the document will be saved as a pdf and an email will be prepared similar to the manner of the current code except the attachment will be a pdf format. I do not need to view the pdf prior to it being sent. The only change to the code is for the attachment to be saved as a pdf prior to the email being prepared. I am using word 365 pro plus. I do not have any sort of MS-Word to PDF converter. To convert the document, I choose 'pdf' as file type when saving the MS-Word file. Thanks. Here is the code: Code:
Private Sub CommandButton1_Click() Dim olkApp As Object Dim strTo As String Dim strBody As String Dim strAtt As String Dim strSubject As String Dim Opara As Range Dim LngPara As Long For LngPara = 1 To ActiveDocument.Paragraphs.Count Set Opara = ActiveDocument.Paragraphs(LngPara).Range If Left(LCase(Opara.Text), 3) = "re:" Then Opara.End = Opara.End - 1 Opara.MoveStartUntil Chr(32) Opara.Start = Opara.Start + 1 strSubject = Opara.Text Exit For End If Next LngPara strBody = "Please see attached file. If you have any questions, please do not hesitate to contact me." strTo = "any@any.com" If ActiveDocument.FullName = "" Then MsgBox "activedocument not saved, exiting" Exit Sub Else If MsgBox("Save Document?", vbYesNo, "Error") <> vbYes Then Exit Sub End If strAtt = ActiveDocument.FullName Set olkApp = CreateObject("outlook.application") With olkApp.createitem(0) .To = strTo .Subject = strSubject .body = strBody .attachments.Add strAtt '.send .Display End With Set olkApp = Nothing End Sub Last edited by macropod; 04-03-2018 at 06:41 PM. Reason: Added code tags |
Tags |
email, pdf |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
zooeyhall | Word | 2 | 10-01-2015 06:22 AM |
![]() |
Catty | Word VBA | 1 | 12-11-2013 03:57 PM |
![]() |
Esgrimidor | Word VBA | 11 | 12-03-2012 03:44 PM |
![]() |
gonner | Word | 1 | 09-10-2011 03:25 AM |
![]() |
vijayaram | Word | 1 | 12-30-2009 08:25 AM |