Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. ' Override File -> Save
  2. Public Sub FileSave()
  3.  
  4. ActiveDocument.Save
  5. SaveActiveDocumentAsPdf
  6.  
  7. End Sub
  8.  
  9. ' Override File -> Save As...
  10. Public Sub FileSaveAs()
  11.  
  12. ActiveDocument.SaveAs
  13. SaveActiveDocumentAsPdf
  14.  
  15. End Sub
  16.  
  17. Sub SaveActiveDocumentAsPdf()
  18.  
  19. On Error GoTo Errhandler
  20.  
  21. If InStrRev(ActiveDocument.FullName, ".") <> 0 Then
  22.  
  23. Dim strPath As String
  24. strPath = Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, ".") - 1) & ".pdf"
  25.  
  26. ActiveDocument.SaveAs2 FileName:=strPath, FileFormat:=wdFormatPDF
  27. End If
  28.  
  29. On Error GoTo 0
  30.  
  31. Exit Sub
  32.  
  33. Errhandler:
  34.  
  35. MsgBox "There was an error saving a copy of this document as PDF. " & _
  36. "Ensure that the PDF is not open for viewing and that the destination path is writable. Error code: " & Err
  37.  
  38. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement