View Single Post
 
Old 07-26-2021, 04:56 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote