Skip to the content
  • +918097817480
  • [email protected]

VinFur

Taxation with pinch of technology

  • Home
  • Blog
  • Client Login
  • Shop
  • Support Portal
  • Cloud Access
  • Api Portal

Mail Merge to PDF

Uncategorized
    • By Vinit Furia
    • No Comments on Mail Merge to PDF
    • December 9, 2021

Mail Merge to PDF

Ever Wondered how Fantastic it would be if Mail Merge Functionality Provided option to create separate Pdf Files.So this Idea Popped to Me When i was Delivering a lecture and a Candidate asked me if it is possible to make a pdf directly and save it on local disk with appropriate name based on a criteria in List of mail merge.

I had Earlier Worked for Creating pdf file on a vast range or excel templates and also on many commercial projects. But Looping this Whole System to create a whole set of Pdf wherein data can be as heavy as 25000+ lines of mail merge.

So I Started off with finding a solution withing excel and ms word as it would have been a very common task for any person using mail merge facility but best bet what i could find was send it via email to multiple receipient hence i thought of modifying old VBA code and creating a Fresh Code For this Purpose

VBA Code

 

 

Sub MailMergeToPdfBasic()
' Last Updated 2021-12-09
' Author Vinit Furia
outputfolder = InputBox("Path To Save Files", "Vinit Furia")
Dim masterDoc As Document, singleDoc As Document, lastRecordNum As Integer

Set masterDoc = ActiveDocument

masterDoc.MailMerge.DataSource.ActiveRecord = wdLastRecord
lastRecordNum = masterDoc.MailMerge.DataSource.ActiveRecord

masterDoc.MailMerge.DataSource.ActiveRecord = wdFirstRecord

Do While lastRecordNum > 0

masterDoc.MailMerge.Destination = wdSendToNewDocument
masterDoc.MailMerge.DataSource.FirstRecord = masterDoc.MailMerge.DataSource.ActiveRecord
masterDoc.MailMerge.DataSource.LastRecord = masterDoc.MailMerge.DataSource.ActiveRecord
masterDoc.MailMerge.Execute False

Set singleDoc = ActiveDocument




singleDoc.ExportAsFixedFormat _
OutputFileName:=outputfolder & Application.PathSeparator & _
masterDoc.MailMerge.DataSource.DataFields("GSTIN").Value & ".pdf", _
ExportFormat:=wdExportFormatPDF

singleDoc.Close False

If masterDoc.MailMerge.DataSource.ActiveRecord >= lastRecordNum Then
lastRecordNum = 0
Else
masterDoc.MailMerge.DataSource.ActiveRecord = wdNextRecord
End If

Loop
End Sub

Here in The Following Code GSTIN is Field Which will Determine the Name of the pdf File.

Leave a Reply Cancel reply

Recent Posts

  • Ais Engine- A tool to download Annual information Statement excel in 1 click
  • Mail Merge to PDF
  • How To Manage Multiple Email Id’s In Single Login with Gmail and Yahoo(Mostly For Clients)
  • Registering DSC (Digital Signature Certificate) On New Income tax portal Along with technical Guidelines
  • Hello world!

Recent Comments

  • Vinit Furia on Ais Engine- A tool to download Annual information Statement excel in 1 click
  • girish on Ais Engine- A tool to download Annual information Statement excel in 1 click
  • Bachelor of Interior Program Telkom University on Registering DSC (Digital Signature Certificate) On New Income tax portal Along with technical Guidelines
  • Bachelor of Interior Program Telkom University on How To Manage Multiple Email Id’s In Single Login with Gmail and Yahoo(Mostly For Clients)
  • Vinit Furia on Registering DSC (Digital Signature Certificate) On New Income tax portal Along with technical Guidelines

Archives

  • September 2022
  • December 2021
  • August 2021
  • June 2021
  • May 2021

Categories

  • Income Tax
  • Software's and tools
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Admin area

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Search The Site

Categories

Proudly powered by WordPress | Theme: Consultera by Wpazure.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkNo
Back To Top