![]() |
#2
|
||||
|
||||
![]()
Maybe something like the following, saved in the document's template. These macros will intercept the save and saveas commands.
Code:
Option Explicit Sub FileSaveAs() On Error Resume Next Dialogs(wdDialogFileSaveAs).Show If Not ActiveDocument.Path = "" Then SaveAsPDF lbl_Exit: Exit Sub End Sub Sub FileSave() On Error Resume Next ActiveDocument.Save SaveAsPDF lbl_Exit: Exit Sub End Sub Sub SaveAsPDF() Dim strDocName As String Dim strPath As String Dim intPos As Integer Start: 'Find position of extension in filename strDocName = ActiveDocument.Name strPath = ActiveDocument.Path & "\" intPos = InStrRev(strDocName, ".") If intPos = 0 Then ActiveDocument.Save GoTo Start End If strDocName = Left(strDocName, intPos - 1) strDocName = strPath & strDocName & ".pdf" ActiveDocument.ExportAsFixedFormat OutputFilename:=strDocName, _ ExportFormat:=wdExportFormatPDF, _ OpenAfterExport:=False, _ OptimizeFor:=wdExportOptimizeForPrint, _ Range:=wdExportAllDocument, From:=1, to:=1, _ Item:=wdExportDocumentContent, _ IncludeDocProps:=True, _ KeepIRM:=True, _ CreateBookmarks:=wdExportCreateHeadingBookmarks, _ DocStructureTags:=True, _ BitmapMissingFonts:=True, _ UseISO19005_1:=False lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
From a docx report document save all images in a cell from the document to a folder | censura | Word VBA | 1 | 05-13-2017 12:54 AM |
![]() |
puff | Word VBA | 3 | 04-19-2017 10:34 AM |
![]() |
Plokimu77 | Word VBA | 4 | 06-05-2016 04:41 PM |
Vba code to save document as pdf using document property text and rename folder. | staicumihai | Word VBA | 1 | 12-21-2015 07:39 AM |
Extract VBA code to save in Word document | Dave T | Word VBA | 4 | 01-26-2015 08:41 PM |