vba - Paste range from word in mail body including the format
问题描述
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
解决方案
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
推荐阅读
- php - 我想在我的文本文件中换行
- node.js - Fullcalendar 上的鼠标位置工具提示,(Tippy,Tooltip.js)
- redirect - JSF/Mojarra ExternalContext.redirect() 创建一个 HttpSession
- python - 错误 Python:时间数据 'Oct 22 2019 12:58:45:196AM' 与格式 '%b %d %Y %H:%M:%S:%f%p' 不匹配(匹配)
- django-rest-framework - 有没有一种简单的方法可以为 ViewSet 中的每个视图添加标题?
- websphere - 需要在 IBM Websphere 和我的自定义应用程序之间进行 SSO
- java - 如何将 Checkbox 的 onCheck 事件传递给 zk 中的父级?
- node.js - 检索通过输入属性传递给子组件的值
- java - Vaadin 14 - 使用渲染的删除按钮删除一行网格
- visual-studio - Visual Studio 程序集 - 我不明白为什么我的程序集代码给了我这个值