问题
I'm working on a mail merge macro and I'm trying to copy the text from my word document including the format in the mail body unfortunately it doesn't accept the range.paste function there. Looking forward to any advice.
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open FileName:="*\Flightticket.docx", ReadOnly:=True
Set oDoc = oWord.ActiveDocument
Set oRange = ActiveDocument.Range(Start:=0)
oWord.Visible = False
oRange.Copy
*
*
*
With oMail
.To = oContact.Email1Address
.Subject = Left(oDoc.Name, Len(oDoc.Name) - 5) & " " & mText
.GetInspector.Activate 'Signatur
olOldBody = .HTMLBody
'The content of the document is used as the body for the email
.HTMLBody = oRange.Paste & olOldBody 'Here is the error
End With
回答1:
I now worked around the problem with adding html code to my word document and included the whole content without copy-paste. This worked out pretty good.
.HTMLBody = oDoc.Content & olOldBody
回答2:
.HTMLBody = oRange.FormattedText & olOldBody
来源:https://stackoverflow.com/questions/61078368/paste-range-from-word-in-mail-body-including-the-format