Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2020, 12:36 PM
kuankailok kuankailok is offline VBA code to CC multiple people in mail merge by word Windows 10 VBA code to CC multiple people in mail merge by word Office 2016
Novice
VBA code to CC multiple people in mail merge by word
 
Join Date: Apr 2020
Posts: 2
kuankailok is on a distinguished road
Default VBA code to CC multiple people in mail merge by word


I have difficulties in writing a VBA code that allow the mail merge to cc people that I would like to loop in. I’ve checked this one (https://www.msofficeforums.com/mail-...ilmerge-3.html) but have no idea which rows to delete as I do no need to send it out with attachment. My situation is:
- To e-mail in cell A1 and copy people in A2, A3... if it’s not blank
and so on......

Currently I’ve applied a code that allows me to adapt dynamic subject line...
Reply With Quote
  #2  
Old 04-27-2020, 02:16 PM
macropod's Avatar
macropod macropod is offline VBA code to CC multiple people in mail merge by word Windows 7 64bit VBA code to CC multiple people in mail merge by word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

To omit attachments, you could simply delete:
Code:
    For i = 2 To Maillist.Tables(1).Columns.Count
      Set datarange = Maillist.Tables(1).Cell(j, i).Range
      datarange.End = datarange.End - 1
      .Attachments.Add Trim(datarange.Text), olByValue, 1
    Next i
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-04-2020, 05:52 AM
kuankailok kuankailok is offline VBA code to CC multiple people in mail merge by word Windows 10 VBA code to CC multiple people in mail merge by word Office 2016
Novice
VBA code to CC multiple people in mail merge by word
 
Join Date: Apr 2020
Posts: 2
kuankailok is on a distinguished road
Default

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
This is the code i'm using to obtain a dynamic subject, however, looks like i cannot put it in the right position? Could you please help?

Additionally, do i need to change anything in your provided code (as i saw there is a ".Cell(j,i)".

Thanks for your help anyway

*** if needed, i could put my sample doc here for your kind checking.... my purpose is to send out email by mail merge with a dynamic subject while copying the right personnel in each individual email, i know that's crazy but wanna complete this in a very short time....typing out each email takes time............

Last edited by kuankailok; 05-04-2020 at 05:54 AM. Reason: added some more comments
Reply With Quote
  #4  
Old 05-04-2020, 02:08 PM
macropod's Avatar
macropod macropod is offline VBA code to CC multiple people in mail merge by word Windows 7 64bit VBA code to CC multiple people in mail merge by word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The code you've posted is nothing like the code discussed in the link you posted. All that means is you've wasted my time. Waste someone else's - preferably your own.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to CC multiple people in mail merge by word Word Mail Merge Envelope Addresses with Multiple Conditions Pedro007 Mail Merge 2 11-19-2019 07:25 AM
VBA code to CC multiple people in mail merge by word Mail Merge Student Transcript - Multiple Years from multiple sheets aizah2018 Mail Merge 1 11-11-2018 01:27 AM
VBA code to CC multiple people in mail merge by word Mail Merge Code Issue Andrewwill Mail Merge 6 01-06-2018 10:25 PM
Mail Merge to multiple employees in multiple locations as PDF by location GFiz Mail Merge 1 05-13-2017 08:01 PM
VBA code to CC multiple people in mail merge by word Mail Merge Multiple Rows -word(from Spain) luisaranda Mail Merge 6 03-06-2016 09:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:13 AM.


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