View Single Post
 
Old 08-30-2011, 01:42 PM
gmaxey gmaxey is offline Windows XP Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Option Explicit
 
Sub MyCustomSaveAs()
Dim strPath As String
Dim oDoc As Word.Document
Dim strName As String
Set oDoc = ActiveDocument
strPath = GetDocPath
strName = m_oDoc.Name
With Dialogs(wdDialogFileSaveAs)
  .Name = strPath & "\" & strName
  If .Show = -1 Then
    If SaveInvoiceAsPDF(m_oDoc) = True Then
      MsgBox "A PDF document was created when you saved this document."
    End If
  End If
End With
lbl_Exit:
Exit Sub
End Sub
 
Function SaveInvoiceAsPDF(ByRef oDocPassed As Word.Document) As Boolean
Dim strFileName As String
SaveInvoiceAsPDF = False
strFileName = Left(oDocPassed.FullName, Len(oDocPassed.FullName) - 4) & "pdf"
  oDocPassed.ExportAsFixedFormat OutputFileName:=strFileName, _
  ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
  wdExportOptimizeForPrint, _
  Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
  CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
  BitmapMissingFonts:=True, UseISO19005_1:=True
SaveInvoiceAsPDF = True
lbl_Exit:
Exit Function
End Function
 
Function GetDocPath() As String
Dim fDlg As Dialog
Set fDlg = Dialogs(wdDialogToolsOptionsFileLocations)
With fDlg
  .Path = "DOC-PATH"
  .Update
  GetDocPath = .Setting
End With
lbl_Exit:
Exit Function
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by macropod; 09-04-2011 at 02:52 AM. Reason: Added code tags & formatting
Reply With Quote