Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2011, 12:39 PM
cc9083 cc9083 is offline Macro to convert word file into pdf Windows XP Macro to convert word file into pdf Office 2000
Novice
Macro to convert word file into pdf
 
Join Date: Aug 2011
Posts: 1
cc9083 is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 08-30-2011, 01:42 PM
gmaxey gmaxey is offline Macro to convert word file into pdf Windows XP Macro to convert word file into pdf Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
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
  #3  
Old 02-23-2015, 01:22 AM
Jagdev Jagdev is offline Macro to convert word file into pdf Windows 7 64bit Macro to convert word file into pdf Office 2010 64bit
Novice
 
Join Date: Nov 2014
Posts: 15
Jagdev is on a distinguished road
Default

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
Reply With Quote
Reply

Tags
macro, pdf

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to convert word file into pdf Macro to convert text to endnote? Orifacious Word VBA 27 03-29-2022 02:58 PM
Macro to convert word file into pdf Word Macro That Checks a Check Box Form Field When File Print is Executed DKerne Word VBA 4 06-09-2011 11:54 AM
Macro to convert word file into pdf Creating macro to convert/print to pdf shabbaranks Word 3 05-18-2011 08:59 AM
Macro to convert word file into pdf 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:14 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