Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2011, 04:08 AM
shabbaranks shabbaranks is offline Macro to save as PDF but with a different name Windows 7 64bit Macro to save as PDF but with a different name Office 2007
Advanced Beginner
Macro to save as PDF but with a different name
 
Join Date: Mar 2011
Posts: 89
shabbaranks is on a distinguished road
Default Macro to save as PDF but with a different name

Hi all...

I posted a solution for a macro which saves as a pdf as below:
Sub Word2PDF()
'
' Word2PDF Macro
'
'
ActiveDocument.ExportAsFixedFormat OutputFileName:= _


ActiveDocument.Path & "\" & ActiveDocument.Name & ".pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub

But I would like to be able to save with a different file name - can anyone suggest how I do this? Basically if I have a word doc named temp.docx it creates a pdf with the name temp.docx.pdf and I would like to remove the .docx extension.

Thanks!
Reply With Quote
  #2  
Old 05-19-2011, 06:52 PM
macropod's Avatar
macropod macropod is offline Macro to save as PDF but with a different name Windows 7 32bit Macro to save as PDF but with a different name Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi shabbaranks,

Try:
Code:
Sub Word2PDF()
With ActiveDocument
  .ExportAsFixedFormat OutputFileName:=Split(.FullName, ".")(0) & ".pdf", _
  ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
  OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
  Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
  CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
  BitmapMissingFonts:=True, UseISO19005_1:=False
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-20-2011, 01:02 AM
shabbaranks shabbaranks is offline Macro to save as PDF but with a different name Windows 7 64bit Macro to save as PDF but with a different name Office 2007
Advanced Beginner
Macro to save as PDF but with a different name
 
Join Date: Mar 2011
Posts: 89
shabbaranks is on a distinguished road
Default

Worked like a charm - thanks!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
PowerPoint Crashes every time I try to save/save as Crimson_Ninja PowerPoint 0 05-04-2011 01:54 PM
Macro to Save Help clarkson001 Word 0 02-14-2011 06:41 AM
Macro to save as PDF but with a different name Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM
Macro will not save to normal.dot file when exiting bobbraun Word 1 09-28-2010 06:26 AM
Macro Won't Save lou0915 Word VBA 2 10-17-2009 08:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft