View Single Post
 
Old 07-27-2021, 12:29 AM
JamesWood JamesWood is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Nov 2020
Posts: 37
JamesWood is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
This seems to work:
Code:
Sub listIncluded()
  Dim iLast As Long, iCount As Long
  With ActiveDocument.MailMerge.DataSource
    .ActiveRecord = wdLastRecord
    iLast = .ActiveRecord         '' Store index of the last active record for later use
    .ActiveRecord = wdFirstRecord
    Do
      iCount = iCount + 1
      Debug.Print .ActiveRecord
      DoEvents
      .ActiveRecord = wdNextRecord
    Loop Until .ActiveRecord = iLast
    MsgBox "There are " & iCount & " active records out of " & .RecordCount
  End With
End Sub
Full Disclosure: I didn't invent this code. I sourced it from here vba - How can get a list of included records in a Word Mail Merge Document? - Stack Overflow and made a small adjustment so I could understand it better.


This is very interesting! Thank you! Not completely fool proof (e.g. if you only select one record then it bugs out) but I think I could play with this code and get it to work. Thanks so much
Reply With Quote