Re: Capturing in code the Rtf and Html of a merge document
- From: Marketware <Marketware@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 May 2009 06:58:13 -0700
Thank you for responding to my question! I really appreciate it.
From your response then, I assume the best approach is to capture eachrecord 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
- Follow-Ups:
- Re: Capturing in code the Rtf and Html of a merge document
- From: Doug Robbins - Word MVP
- Re: Capturing in code the Rtf and Html of a merge document
- References:
- Capturing in code the Rtf and Html of a merge document
- From: Marketware
- Re: Capturing in code the Rtf and Html of a merge document
- From: Doug Robbins - Word MVP
- Capturing in code the Rtf and Html of a merge document
- Prev by Date: Re: Tables and inserting rows
- Next by Date: nike clothing,nike shoes,online store,http://www.maidi2008.net air Jordan Shoes,Nike Air Jordans, Air Force Ones,Retro Air Jordan, Bape Hoodies,Bape shoes-Tencent Traveler|Jordan Shoes,Nike Air Jordans, Air Force Ones,Retro Air Jordan, Bape Hood
- Previous by thread: Re: Capturing in code the Rtf and Html of a merge document
- Next by thread: Re: Capturing in code the Rtf and Html of a merge document
- Index(es):
Relevant Pages
|
Loading