Sunday, September 30, 2018

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. Replies
    1. IEEE Final Year projects Project Center in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes. Final Year Project Domains for IT

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, project projects for cse. Angular Training

      Delete
  2. 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
  3. that that move goes. It might be just submitted on well known talking about destinations like YouTube, Facebook, MetCafe. word converter online

    ReplyDelete
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. Awesome article with top quality information and found very interesting looking forward for next blog thank you.
    Data Science Course in Hyderabad 360DigiTMG

    ReplyDelete
  11. Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
    Cyber Security Course in Bangalore

    ReplyDelete
  12. Writing in style and getting good compliments on the article is hard enough, to be honest, but you did it so calmly and with such a great feeling and got the job done. This item is owned with style and I give it a nice compliment. Better!
    Cyber Security Training in Bangalore

    ReplyDelete
  13. I will very much appreciate the writer's choice for choosing this excellent article suitable for my topic. Here is a detailed description of the topic of the article that helped me the most.
    unindent does not match any outer indentation level

    ReplyDelete
  14. I'm glad I found this blog! Occasionally, students want to know the keys to writing productive literary essays. Your first-class knowledge of this great job can become a suitable foundation for these people. Good
    unindent does not match any outer indentation level python

    ReplyDelete

How to Fix ImportError: No module named 'flask' with virtualenv

Flask is one of the most used frameworks in Python. If you are new to the flask and if you are getting this error - ImportError: No module n...