VBA Code to find a record in the MS word mail merge

MS Word mail merge has an option to navigate through the records. The below VBA code will help you to type and search the record within the MS word document area, you do not have to go to the menu bar.

This code first resets the document to the first record. This is required as the mail merge navigation is only forward. That means the VBA code cannot traverse backward.

Reads a text from TextBox which is placed within the document. If the keyword entered and the current record is matched, then the Active document is activated with the current record.


With ActiveDocument.MailMerge
 .DataSource.ActiveRecord = wdFirstRecord
End With

Dim numRecord As Integer
Dim searchText As String
searchText = TextBox1.Text

Set dsMain = ActiveDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:=searchText, Field:="Name") = True Then
numRecord = dsMain.ActiveRecord
End If
End Sub


Watch the complete step by step tutorial


Download the Excel file and the word document from this link below

Download

22 comments:

  1. Thanks for sharing these niche piece of info's to our knowledge. Here, I had a solution for my inconclusive problems & it’s really helps me a lot keep updates…
    Ethical Hacking Course in Chennai
    Hacking Course in Chennai
    Angularjs Training in Chennai
    CCNA Training in Chennai
    Salesforce Training in Chennai
    Ethical Hacking Course in Chennai
    Hacking Course in Chennai

    ReplyDelete
  2. that that move goes. It might be just submitted on well known talking about destinations like YouTube, Facebook, MetCafe. word converter online

    ReplyDelete
  3. There is definately a great deal to find out about this topic. I like all the points you have made.

    Click here to get More information.

    ReplyDelete
  4. You ought to be a part of a contest for one of the finest websites on works the net. I am going to highly recommend this blog!

    ReplyDelete
  5. Spot on with this write-up, I truely take delivery of as authentic with that this wonderful internet website online goals an lousy lot extra interest. I’ll probable be returning to net info study thru greater, thanks for the statistics!

    ReplyDelete
  6. overseas education consultants in chennai

    Read this Review on Best Overseas Educational Consultants in Chennai. Planning to Study Abroad? Choose Trusted Overseas Education Consultancy in Chennai from the list

    ReplyDelete
  7. oracle dba interview questions

    Learn these Oracle Interview Questions to crack the interview and get placed in MNC. prepare well and brush up your knowledge to obtain your desired career.
    oracle interview questions, oracle dba interview questions

    ReplyDelete
  8. java interview questions for experienced

    Are you a fresher who wants to crack the Java Interview Questions and Answers? Here we offer you some of the major Core Java Interview Questions for Freshers.
    java interview questions for experienced

    ReplyDelete
  9. Awesome article with top quality information and found very interesting looking forward for next blog thank you.
    Data Science Course in Hyderabad 360DigiTMG

    ReplyDelete
  10. Nice post, I like to read this blog. It is very interesting to read.
    python class inheritance
    length of string in python

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. But...before we get into this...I might want to give you an expression of alert. Huge Mail selling looks simple and it sounds simple IT IS NOT! Selling Big Mails is a great deal of work,HARD WORK. Also, it's anything but an approach to make easy money. instant sales leads

    ReplyDelete
  13. Awesome Article we appreciate your writing and keep posting articles like this.

    instagram video download

    ReplyDelete
  14. Replay Media Catcher is an easy-to-use online video downloader, recorder and converter software that supports dozens of online websites. The .Replay Media Catcher 8 User Guide

    ReplyDelete
  15. EasyUEFI Enterprise 4.9.2.0 Crack is an easy-to-use EFI / UEFI boot option for boards that allows you to create, delete, modify, delete, merge, and restore EFI .Easyuefi Full Download

    ReplyDelete
  16. Enjoy this special time of the year with those dear to your heart and may the Lord bless you all with a year full of happiness and good health.May God Bless You With All The Happiness And Success Meaning In Hindi

    ReplyDelete

How to copy screenshot to clipboard in New Apple Mac OS

If you have upgraded your Apple Mac OS to 14.x.x, then you may find it strange that the screenshots are not copied into the clipboard. The s...