Re: Capturing in code the Rtf and Html of a merge document



I do not know about RTF, but you can certainly do it in plain format as is done in the code in the article "Mail Merge to E-mail with Attachments" at:

http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm

a version of that, which had been modified to create an email in HTML format was the basis of the code that I posted.

The way in which the recipient views the email message is of course dependent upon the way in which they have their newsreader configured.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Marketware" <Marketware@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:83E845E1-7CCD-4BF8-9D47-9DCA12C19975@xxxxxxxxxxxxxxxx
Thank-you yes, I realized that. Could you please respond to my questions?
Thank you.

bob

"Doug Robbins - Word MVP" wrote:

The code that I posted captures the document created for each record in the
data source, not the record.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Marketware" <Marketware@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4033196D-8047-4305-9D81-AD35790E907A@xxxxxxxxxxxxxxxx
> Thank you for responding to my question! I really appreciate it.
>
> From your response then, I assume the best approach is to capture each
> record via the clipboard?
>
> What I am trying to do is capture the body of the merge document > (merged)
> like this:
>
> Dear <<Saluation>>:
>
> I hope all is well at <<Company_Name>>...
>
> Convert it to:
>
> Dear Fred:
>
> I hope all is well at ABC Company...
>
> And take the merged data and insert it into the body of the email.
>
> Now the question I have from your response is...I notice you are
> attempting
> to invoke the .WordEditor and you've set the format to HTML.
>
> Is HTML the only format that this will work with reliably? Or can you > do
> it
> with Rich Text or Plain Text too? Also, can you set the Format on the > fly
> or
> are you limited to the message format the end user has set in his/her
> Options?
>
> Thank you sooooooo much!!!
>
> bob
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> The following code contains where indicated by the **** the commands
>> necessary to create such an email message. If you were to use >> something
>> similar and omit the .Send command, the email message will probably be
>> available for the user to edit it if necessary and then send it >> manually.
>>
>> Dim Source As Document, Maillist As Document, TempDoc As Document
>> Dim DataRange As Range
>> Dim i As Long, j As Long
>> Dim bStarted As Boolean
>> Dim oOutlookApp As Outlook.Application
>> Dim oItem As Outlook.MailItem
>> Dim mysubject As String, message As String, Title As String
>>
>> Set Source = ActiveDocument
>>
>> ' Check if Outlook is running. If it is not, start Outlook
>> On Error Resume Next
>> Set oOutlookApp = GetObject(, "Outlook.Application")
>> If Err <> 0 Then
>> Set oOutlookApp = CreateObject("Outlook.Application")
>> bStarted = True
>> End If
>>
>> ' Open the catalog mailmerge document
>> With Dialogs(wdDialogFileOpen)
>> .Show
>> End With
>> Set Maillist = ActiveDocument
>>
>> ' Show an input box asking the user for the subject to be inserted >> into
>> the
>> email messages
>> message = "Enter the subject to be used for each email message." ' >> Set
>> prompt.
>> Title = " Email Subject Input" ' Set title.
>> ' Display message, title
>> mysubject = InputBox(message, Title)
>>
>> ' Iterate through the Sections of the Source document and the rows of >> the
>> catalog mailmerge document,
>> ' extracting the information to be included in each email.
>> For j = 1 To Source.Sections.Count - 1
>> Source.Sections(j).Range.Copy
>> Set oItem = oOutlookApp.CreateItem(olMailItem)
>> With oItem
>> .Subject = mysubject
>> '****
>> .BodyFormat = olFormatHTML
>> .Display
>> Set objDoc = .GetInspector.WordEditor
>> Set objSel = objDoc.Windows(1).Selection
>> objSel.Paste
>> '****
>> Set DataRange = Maillist.Tables(1).Cell(j, 1).Range
>> DataRange.End = DataRange.End - 1
>> .To = DataRange
>> 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
>> .Send
>> End With
>> Set oItem = Nothing
>> Next j
>> Maillist.Close wdDoNotSaveChanges
>>
>>
>> -- >> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>> "Marketware" <Marketware@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:2FD8DC29-34E2-4E16-B01D-C13EA2BEDF14@xxxxxxxxxxxxxxxx
>> >I would like to create mail merge letters in word and use those for
>> >outlook
>> > as form emails after merging the data into the document. (one at a
>> > time
>> > so
>> > the user can make any changes in the inspector before pressing send)
>> >
>> > What is the appropriate properties from the word document that could
>> > give
>> > me
>> > the rtf and the HTML code from the word document after it has been
>> > merged?
>> >
>> > for example
>> >
>> > outlookobject.HTMLbody = activedocument.??? //html email
>> >
>> > outlookobject.RTFbody = activedocument.??? //rtf email
>> >
>> > outlookobject.body = activedocument.??? //text email
>> >
>> > Thanks in Advance!!
>> >
>> > bob
>> >
>> >
>> >
>>
>>



.



Relevant Pages

  • Re: Mail Merge HTML Format Word 2002 XP SP3
    ... of using mailmerge to create the personalised content of the email message, ... The body text format determines the standard used to display the text of the ... Text, Rich Text, and HTML. ... Dim olApp As Outlook.Application ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Replacing Text w/Autotext - Greg, Ed, Graham,Russ
    ... Word MVP web site http://word.mvps.org ... Dim vFindText As Variant ... .Format = False ...
    (microsoft.public.word.vba.general)
  • Re: LINK field in Word - Pasting from Excel
    ... The following macro will change all the mergeformat switches in a document ... Dim oStory As Range ... Word MVP web site http://word.mvps.org ... adding \f 4 to format as per the Word document ...
    (microsoft.public.word.docmanagement)
  • Re: How can I place a superscript number directly above a subscript?
    ... it might be easier to format the EQ field if you used ... the \A switch rather than the \O switch. ... Dim sNum As String ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Re: Automating color on specific text.
    ... Dim vFindText As Variant ... .Format = True ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.newusers)