Link to home
Start Free TrialLog in
Avatar of Stephen Byrom
Stephen ByromFlag for Ireland

asked on

email Word.docm as PDF

Hi,
I have code (attached) that works as far as sending the document as a macro enabled document.
I have tried messing around with the "activedocument.fullname" part to change it to have a PDF suffix, but with my limited knowledge of VBA i'm getting nowhere.

What I would like the code to do is send the current word document as a PDF file to email recipients instead of a macro enabled document, as people need to open it on their smart phones so PDF is the best option.

As always any help is greatly appreciated.

Dim olkApp As Object
Dim strSubject As String
Dim strTo As String
Dim strBody As String
Dim strAtt As String
ActiveDocument.Save
    strSubject = "Plant 2 Downtime document"
    strBody = "Please see attached File"
'   strTo = "someone@somefirm.com"
    strTo = "me@somewhereelse.com"
    If ActiveDocument.FullName = "" Then
        MsgBox "activedocument not saved, exiting"
        Exit Sub
    Else
        If ActiveDocument.Saved = False Then
            If MsgBox("Activedocument NOT saved, Proceed?", vbYesNo, "Error") <> vbYes Then Exit Sub
        End If
    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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stephen Byrom

ASKER

Thanks, it was the "wdFormatPDF" that eluded me.