我正在尝试从Excel自动安排会议 这很简单,除非你试图格式化正文 我对GetInspector进行了一些研究 看起来我必须从其他地方复制文本,但我发现的命令不正确或不起作用。甚至尝试将其格式化为RTF,但.RTFBody不是AppointmentItem对象的属性
找到我的代码:
Dim oApp As Object
Dim oMail As Object
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(1)
With oMail
.Subject = ""
.Location = ""
'.Start =
'.Duration =
.body = " < not formattable text >"
.display
End With
Set oApp = Nothing
Set oMail = Nothing
答案 0 :(得分:0)
我曾经问过这个问题,并在这里得到答案(http://www.slipstick.com/developer/code-samples/paste-formatted-text-vba/)
尝试以下方法。您需要设置对Word对象模型的引用,并且格式化的文本应存储在剪贴板中,注意,您必须在.display
行之前有.body
行才能存在可以使用的东西:
Dim oApp As Object
Dim oMail As Object
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(1)
With oMail
.Subject = ""
.Location = ""
'.Start =
'.Duration =
' .body = " < not formattable text >"
.display
End With
Dim objItem As Object
Dim objInsp As Outlook.Inspector
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objSel As Word.Selection
Set objItem = oMail ' Application.ActiveInspector.currentItem
Set objInsp = objItem.GetInspector
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application
Set objSel = objWord.Selection
objSel.PasteAndFormat (wdFormatOriginalFormatting)
'objSel.PasteAndFormat (Word.WdRecoveryType.wdFormatOriginalFormatting)
Set objItem = Nothing
Set objInsp = Nothing
Set objDoc = Nothing
Set objWord = Nothing
Set objSel = Nothing
Set oApp = Nothing
Set oMail = Nothing
H个