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