Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #27  
Old 06-30-2014, 01:22 AM
toughiv toughiv is offline Mail Merging - Mergeseq + Send Via Email Merge Windows Vista Mail Merging - Mergeseq + Send Via Email Merge Office 2010 32bit
Novice
Mail Merging - Mergeseq + Send Via Email Merge
 
Join Date: Jun 2014
Posts: 21
toughiv is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Your attachments look OK, but the 'Coding.doc' isn't saved as a mailmerge main document and you didn't attach the problem output document generated by the merge (i.e. the 'Email Merge Main Document' file).
It wouldnt allow me to attach the relevant version of the document - It kept saying invalid.

I have attached the coding I used from the tutorial doc.

Since Im having difficulty attaching, could you not start a new word doc, start directory merge - copy and paste the code across and then paste this code into the developer:

Code:
Sub RunMerge()
Application.ScreenUpdating = False
Dim Doc1 As Document, Doc2 As Document, Doc3 As Document, StrDoc As String
Set Doc1 = ThisDocument
StrDoc = ThisDocument.Path & "\EmailDataSource.doc"
If Dir(StrDoc) <> "" Then Kill StrDoc
With Doc1.MailMerge
  If .State = wdMainAndDataSource Then
    .Destination = wdSendToNewDocument
    .Execute
    Set Doc2 = ActiveDocument
  End If
End With
Call EmailMergeTableMaker(Doc2)
With Doc2
  .SaveAs FileName:=StrDoc, AddToRecentFiles:=False, FileFormat:=wdFormatDocument
  StrDoc = .FullName
  .Close
End With
Set Doc2 = Nothing
Set Doc3 = Documents.Open(FileName:=Doc1.Path & "\Email Merge Main Document.doc", _
  AddToRecentFiles:=False)
With Doc3.MailMerge
  .MainDocumentType = wdEMail
  .OpenDataSource Name:=StrDoc, ConfirmConversions:=False, ReadOnly:=False, _
    LinkToSource:=True, AddToRecentFiles:=False, Connection:="", SQLStatement:="", _
    SQLStatement1:="", SubType:=wdMergeSubTypeOther
  If .State = wdMainAndDataSource Then
    '.Destination = wdSendToNewDocument
    .Destination = wdSendToEmail
    .MailAddressFieldName = "Outstanding Invoices"
    .MailSubject = "Monthly Sales Stats"
    .MailFormat = wdMailFormatHTML
    .Execute
  End If
End With
Doc3.Close SaveChanges:=False
Set Doc3 = Nothing
Application.ScreenUpdating = True
End Sub
Sub EmailMergeTableMaker(DocName As Document)
Dim oTbl As Table, i As Integer, j As Integer, oRow As Row, oRng As Range, strTxt As String
With DocName
  .Paragraphs(1).Range.Delete
  Call TableJoiner
  For Each oTbl In .Tables
  j = 2
    With oTbl
      i = .Columns.Count - j
      For Each oRow In .Rows
        Set oRng = oRow.Cells(j).Range
        With oRng
          .MoveEnd Unit:=wdCell, Count:=i
          .Cells.Merge
          strTxt = Replace(.Text, vbCr, vbTab)
          On Error Resume Next
          If Len(strTxt) > 1 Then .Text = Left(strTxt, Len(strTxt) - 2)
        End With
      Next
    End With
  Next
  For Each oTbl In .Tables
    For i = 1 to j
      oTbl.Columns(i).Cells.Merge
    Next
  Next
  With .Tables(1)
    .Rows.Add BeforeRow:=.Rows(1)
    .Cell(1, 1).Range.Text = "Recipient"
    .Cell(1, 2).Range.Text = "Data"
  End With
  .Paragraphs(1).Range.Delete
  Call TableJoiner
End With
Set oRng = Nothing
End Sub
Private Sub TableJoiner()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
  With oTbl.Range.Next
    If .Information(wdWithInTable) = False Then .Delete
  End With
Next
End Sub
I hope that isnt too much trouble?

Thanks!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merging - Mergeseq + Send Via Email Merge mail merge in excel to send pdf forms heyullama Excel 7 12-01-2013 03:32 PM
Mail Merge Many URLs in one email by common email address instantaphex Mail Merge 3 04-29-2013 05:46 PM
Mail Merge to email, changing images on email layout ginelli Mail Merge 18 02-23-2013 09:47 AM
Mail Merging - Mergeseq + Send Via Email Merge Mail Merge with Booklets is Merging all documents into One stapled Booklet 15Degrees Mail Merge 1 01-31-2013 02:06 AM
Send e-mail message in Finish & Merge CDTom Mail Merge 1 08-24-2012 12:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:05 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