Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-11-2013, 06:02 AM
Catty Catty is offline Convert word document to pdf Windows 7 32bit Convert word document to pdf Office 2010 32bit
Advanced Beginner
Convert word document to pdf
 
Join Date: Nov 2013
Posts: 39
Catty is on a distinguished road
Default Convert word document to pdf

Hi,

I am trying to create a macro that will enable the user to save a word document as pdf.
Below are the steps which must happen in order:

1. Click SaveAsPdf button
2. An input box appears asking user to name the document.
3. Convert word document to pdf
4. A dialog box appears enabling the user to browse and select location to save the pdf
5. Attach the pdf on a new email as an attachment in outlook.
6. Msgbox pops up asking the user if they want to save the word document. If Yes, repeat step 4 (dialog box must default
to the location where the pdf was saved).




My macro takes care of steps 1, 2, 3 and 5. I am having difficulties with step 4. Any help would be much appreciated.

Below is my code:

Code:
Sub SaveAsPDF()
Dim dlgSaveAs As FileDialog, strFile As String
Dim strPath As String

'Renaming document and selecting path to save to
strFile = InputBox("Please Enter Filename")

On Error Resume Next

'Converting document to pdf

ActiveDocument.ExportAsFixedFormat OutputFileName:= _
        strFile _
        , ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentWithMarkup, IncludeDocProps:=False, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
        
MsgBox "Document converted to .pdf, please select location to save"

Set dlgSaveAs = Application.FileDialog(msoFileDialogFolderPicker)
dlgSaveAs.InitialFileName = "default path"
dlgSaveAs.Show

If Err Then MsgBox "Document not saved": Exit Sub

'Saving the document
ActivePresentation.SaveAs strFile

MsgBox "You saved the file to:" & vbNewLine & strFile



End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do I Convert XML to Word? Synful Word 13 11-23-2014 02:18 PM
Convert word document to pdf Convert a word document in an empty one with backgrounds Esgrimidor Word VBA 11 12-03-2012 03:44 PM
Convert word document to pdf How to convert PDF to word on Mac? priya Word 1 10-07-2011 11:03 AM
Convert word document to pdf PDF to Word(.doc) document not convert correctly gonner Word 1 09-10-2011 03:25 AM
Convert word document to pdf Convert word document to JPEG. The word document may contain headerfooters vijayaram Word 1 12-30-2009 08:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft