Solved

email Word.docm as PDF

Posted on 2013-12-09
2
625 Views
Last Modified: 2013-12-09
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

0
Comment
Question by:Stephen Byrom
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility
You can save a document as PDF, so:
   
ActiveDocument.SaveAs "C:\MyFolder\MyDoc.pdf", wdFormatPDF

Open in new window

0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
Comment Utility
Thanks, it was the "wdFormatPDF" that eluded me.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now