#16
|
|||
|
|||
Quote:
The data source is a bunch of one line tables that have "]" Seperating them. I have made sure there are no extra paragraph marks. The key field is set as company name. Instead of "recipient" I have the email address merge field. I have tried running the macro with the tutorial files, using the tutorial data source. It results in the same one row tables separated by "]". I will be at my work computer in an hour. I will upload a sample if you wouldn't mind? Im so close I can't almost taste it! Thanks |
#17
|
||||
|
||||
What that means is that you have copied the ']' character that follows the field into the mailmerge main document! You should only have the field, not the '[' or ']' either side of it...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#18
|
|||
|
|||
Quote:
Thanks macro |
#19
|
||||
|
||||
Quote:
Quote:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#20
|
|||
|
|||
The problem being - i skimmed all the way until page 25...
I then just saw the bit about copy this and make sure you have no extra paragraph marks. With both statements - you are correct. Its very obvious. I did remove the "]" now. And it seems to be working! Hurrah! ... slight and now is only a slight problem. I have attached a jpeg of the error message. I think it could be where the recipient is within the quotation marks. Therefore, I have attached a screenshot of the coding & the email main merge document template I use. Is it because I have recipient in the table of the directory? **P.s. - when it sends the email it is all in plain text. - what line would i use where it says "plaintext" in the macro? Also - there is no gap between the "with yourselves are:..." & then the table. Is that because it is plain text? Thanks!!! |
#21
|
||||
|
||||
The Outlook Message is probably the result of one of your Outlook settings. Perhaps the 'Automatic name checking' option under File|Options|Mail>Send messages. I don't use Outlook, so I can't be sure which option it might be but that one look like a good place to start. I note too that your error-message screenshot shows the same email address three times. That suggests you're still trying to send three emails to the same person. That's probably because you have an email address in each record. The simplest fix is to have the email address in only the first record for each group; otherwise some additional field coding would be required to eliminate duplicates (I don't have time for that right now - studying for a Uni exam).
The spacing between the "with yourselves are:..." and the table can probably be handled by inserting a couple of line breaks/paragraph breaks between them in the source file. To send the emails in HTML format, you'd change: .MailFormat = wdMailFormatPlainText to: .MailFormat = wdMailFormatHTML
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#22
|
|||
|
|||
thank you macro.
Btw! You are a legend. I got the merge working! One little thing - an issue with alignment now. While i get all the records grouped and merged...for some reason a couple of the lines a few rows down...seem to be on a different margin / begin further toward the middle of the page. The excel spreadsheet has all of the cells aligned the same. Do you have an idea what might be causing this? Im gonna have a mess around and try figure it out myself Thanks |
#23
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#24
|
|||
|
|||
Is there a way I should write emails into a cell if there are more than one for the company?
I assumed it would be: email1@nowhere.com;email2@nowhere.com. It doesnt work though? Is that a limitation? Thanks |
#25
|
||||
|
||||
I'd have thought: email1@nowhere.com; email2@nowhere.com (i.e. with a space after the semi-colon). An alternative might be to create group in Outlook, then use the group name in the mailmerge.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#26
|
|||
|
|||
Quote:
I'll admit straight off the bat- I have replaced a merge field as I was trying to send a different directory from a different excel worksheet. The worksheet itself was pretty much the same, maybe a few extra columns, but the data itself from the same program. For some weird reason - the table joiner is working but in an odd fashion. When I look at the data source, the tables are merged, but the first row becomes merged in its own table, then the subsequent rows ( say 20) get merged into a different box below the first row. The results in only the first row of data being merged and sent. I looked at the code - no extra paragraphs, no [] markers like previously. Any ideas? Thanks mac |
#27
|
||||
|
||||
Without seeing the problem document and the mailmerge document it was created from, it would be difficult for anyone to diagnose the issue. Can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#28
|
|||
|
|||
I have attached the files.
Thanks for having a look at this Macro. |
#29
|
||||
|
||||
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).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#30
|
|||
|
|||
Quote:
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 Thanks! |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 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 |