#1
|
|||
|
|||
Macro to convert word file into pdf
Hi people. I'm new here. Need your guidance on this.
I have both MS Word & Acrobat Standard 9 installed in my PC. My work requires me to issue correspondence letters to customers & suppliers. There are lots of word files that needs to be pdf. When I save a letter under a name, I also need to have a pdf copy. Both documents (.doc & .pdf) will be saved in the same folder. I need a macro to do the following for me. Once I saved the .doc, I run the macro and it will automatically save a copy under the same name in pdf in the same folder. Appreciate all your help here & thanks in advance. |
#2
|
|||
|
|||
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 Last edited by macropod; 09-04-2011 at 02:52 AM. Reason: Added code tags & formatting |
#3
|
|||
|
|||
Hi Grey
I have the same requirement but I have word doc saved in a a folder and have to convert them in to PDF. Regards, JD |
Tags |
macro, pdf |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to convert text to endnote? | Orifacious | Word VBA | 27 | 03-29-2022 02:58 PM |
Word Macro That Checks a Check Box Form Field When File Print is Executed | DKerne | Word VBA | 4 | 06-09-2011 11:54 AM |
Creating macro to convert/print to pdf | shabbaranks | Word | 3 | 05-18-2011 08:59 AM |
Word Macro: Save file as text with current file name | jabberwocky12 | Word VBA | 2 | 10-22-2010 12:23 PM |
Convert a file from HTML to WORD format weblayout view | gtselvam | Word | 0 | 12-02-2008 03:53 AM |