logo WhatsApp



VBA CODE . Copy and Paste in your word file in any module

Sub Pdf_files_from_word_Ajit()
Dim fs
Application.ScreenUpdating = False
Dim DocName, PDFPath, Folderpath, From, Till, Message
Folderpath = "C:\Users\Kumar Ajit\Desktop\ALL PDF" ' Check this path in case any error
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FolderExists(Folderpath) = False Then
fs.createfolder (Folderpath)
Else
End If
From = 1
Till = 3
Message = (Till - From) + 1
While From <= Till
ActiveDocument.MailMerge.DataSource.ActiveRecord = From
DocName = ActiveDocument.Fields(1).Result
PDFPath = Folderpath & "\" & DocName & ".pdf"
Massage = ((Till - From) + 1)
ActiveDocument.ExportAsFixedFormat OutputFileName:=PDFPath, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportFromTo, Item:=wdExportDocumentContent, IncludeDocProps:=True
From = From + 1
Wend
MsgBox (Message & " Pdf Files Saved In = " & Folderpath & " Thanks for using AKumar Utility, 99Excel.Com")
End Sub