Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2016, 01:27 AM
MailMergeConfused MailMergeConfused is offline When using a 'Master' template, if number of records change, subsequent records will not be read Windows 7 64bit When using a 'Master' template, if number of records change, subsequent records will not be read Office 2013
Novice
When using a 'Master' template, if number of records change, subsequent records will not be read
 
Join Date: Jul 2016
Posts: 3
MailMergeConfused is on a distinguished road
Default


Quote:
Originally Posted by DougMVP View Post
It may help if you post the code that you have in the macro as the behaviour that you report is definitely not normal.
Code:
Dim WithEvents wdapp As Application
Dim EMAIL_SUBJECT As String
Dim FIRST_RECORD As Boolean


Private Sub Document_Open()

    Set wdapp = Application
    ThisDocument.MailMerge.ShowWizard 1
   
End Sub

Private Sub Document_Close()

    Set wdapp = Nothing
    
End Sub


Private Sub wdapp_MailMergeBeforeRecordMerge(ByVal Doc As Document, Cancel As Boolean)
    Dim i As Integer
    
    With ActiveDocument.MailMerge
    
        If FIRST_RECORD = True Then
            EMAIL_SUBJECT = .MailSubject
            FIRST_RECORD = False
        Else: .MailSubject = EMAIL_SUBJECT
        End If

        i = .DataSource.DataFields.Count
        
        Do While i > 0
            .MailSubject = Replace(.MailSubject, "<" & .DataSource.DataFields(i).Name & ">", .DataSource.DataFields(i).Value, , , vbTextCompare)
            i = i - 1
        Loop

    End With
    
     
End Sub


Private Sub wdapp_MailMergeBeforeMerge(ByVal Doc As Document, ByVal StartRecord As Long, ByVal EndRecord As Long, Cancel As Boolean)

    FIRST_RECORD = True
    
End Sub

Private Sub wdapp_MailMergeAfterMerge(ByVal Doc As Document, ByVal DocResult As Document)

    ActiveDocument.MailMerge.MailSubject = EMAIL_SUBJECT
     
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
When using a 'Master' template, if number of records change, subsequent records will not be read Grouping records by supplier Franci Mail Merge 2 07-19-2016 10:25 PM
if address is repeated in subsequent records paulys Mail Merge 7 12-08-2014 04:10 PM
Combining two different records into one JemmyRi Mail Merge 1 10-17-2014 05:29 AM
Change handout master in PowerPoint custom template porland PowerPoint 0 10-02-2014 01:55 PM
Records paragraph break ervilhaman Mail Merge 14 04-09-2013 02:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft