Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Override File -> Save
- Public Sub FileSave()
- ActiveDocument.Save
- SaveActiveDocumentAsPdf
- End Sub
- ' Override File -> Save As...
- Public Sub FileSaveAs()
- ActiveDocument.SaveAs
- SaveActiveDocumentAsPdf
- End Sub
- Sub SaveActiveDocumentAsPdf()
- On Error GoTo Errhandler
- If InStrRev(ActiveDocument.FullName, ".") <> 0 Then
- Dim strPath As String
- strPath = Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, ".") - 1) & ".pdf"
- ActiveDocument.SaveAs2 FileName:=strPath, FileFormat:=wdFormatPDF
- End If
- On Error GoTo 0
- Exit Sub
- Errhandler:
- MsgBox "There was an error saving a copy of this document as PDF. " & _
- "Ensure that the PDF is not open for viewing and that the destination path is writable. Error code: " & Err
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement