#1
|
|||
|
|||
Word Macro to publish document as pdf (Word 2010)
In Word 2010, the only way to save word doc (.docx) and publish it as pdf (pdf preview) is as follows :
File > Save & Send > Create PDF/XPS Document > Create PDF/XPS > Publish Above series of clicks opens a window titled 'Publish as PDF or XPS' with original file name but file type as PDF (in the same path or directory as original .docx file). I recorded a macro using the series of steps above by opening a blank doc1.docx file. The macro runs perfectly well. My problem is that when i run this macro on any other word file it still ends up at c:user/documents directory as doc1.pdf. I would like the macro to create pdf file with same file name and in the same directory and show the pdf preview (as the series of clicks above does it). Can someone help? (File > Save as > PDF does not publish or bring up the pdf preview but simply saves it to the same directory with same file name but pdf extension) The VBA code generated in my macro is: Code:
Sub pdf() ' pdf Macro ActiveDocument.ExportAsFixedFormat OutputFileName:= _ "C:\Users\username\Documents\Doc1.pdf", ExportFormat:=wdExportFormatPDF, _ OpenAfterExport:=True, OptimizeFor:=wdExportOptimizeForPrint, Range:= _ wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _ IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _ wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _ True, UseISO19005_1:=False End Sub Thanks in advance (Since i am posting first time here - i dont know if the replies will be sent to my email or i have to access the forum everytime or if i can give my email address here in the post?) Last edited by macropod; 04-10-2013 at 02:12 PM. Reason: Added code tags & formatting |
#2
|
||||
|
||||
Try:
Code:
Sub PDF() ' pdf Macro Dim StrName As String With ActiveDocument StrName = .FullName StrName = Left(StrName, InStrRev(StrName, ".")) & "pdf" .ExportAsFixedFormat OutputFileName:=StrName, UseISO19005_1:=False, _ ExportFormat:=wdExportFormatPDF, OptimizeFor:=wdExportOptimizeForPrint, _ OpenAfterExport:=True, Range:=wdExportAllDocument, From:=1, To:=1, _ Item:=wdExportDocumentContent, IncludeDocProps:=True, _ KeepIRM:=True, CreateBookmarks:=wdExportCreateNoBookmarks, _ DocStructureTags:=True, BitmapMissingFonts:=True End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Works perfectly!
Thanks Paul. |
Tags |
macro vba word, publish pdf |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
MAcro to List all the Font & its size in a word document | shaukat74 | Word VBA | 1 | 01-29-2013 09:34 PM |
Word 2007 can't connect and publish to WordPress | Danielm | Word | 0 | 10-23-2012 12:38 AM |
Macro to read word document | harishankar.selvaraju | Excel Programming | 1 | 06-14-2012 03:48 AM |
Save or publish as Word (or other format) - All notes AND slide text | jfreema | PowerPoint | 0 | 06-18-2010 11:49 AM |
Word 2003 macro to Word 2007 to 2010 to... | maruapo | Word VBA | 0 | 06-04-2010 03:43 PM |