让显示可在任何书面文字/短语(或尽可能频繁)上触发的新邮件撰写的原生VBA方法,或指导如何创建可观察到的动态形式属性。
可能有趣的一个Outlook功能是在编写邮件时知道其可读性值。我知道他们可以通过拼写检查获得,但我想避免做拼写检查以获得结果的负担 - 我希望看到数字在写入邮件时上下 / em>的
我创建了我需要的功能,但是我找不到一个方法,它可以在写入的每个单词中触发它。我认为它类似于WordEditor_Change
,HTMLBody_Change
或类似的东西。它类似于我们在Excel中的Worksheet_Change
,其中可以在编辑Excel工作表时获取值。
我试图设置WordEditor.words.count
的观察值,但也失败了。
WithEvents myMail As Outlook.MailItem
Private Sub Application_ItemLoad(ByVal Item As Object)
Set myMail = Item
End Sub
Sub checkStatistics()
Dim objInsp As Outlook.Inspector
Set objInsp = myMail.GetInspector
'Enum Outlook: https://msdn.microsoft.com/es-es/VBA/Outlook-VBA/articles/olobjectclass-enumeration-outlook
If objInsp.EditorType = olEditorWord Then ' outlook 2013
'Doc obj: https://msdn.microsoft.com/en-us/vba/word-vba/articles/document-object-word
Set objdoc = objInsp.WordEditor
Dim var As ClassHandlesEvent
Dim tst As classWithEvent
Set var = New ClassHandlesEvent
Set tst = New classWithEvent
var.EventVariable = tst
tst.value = objdoc.Words.Count
MsgBox objdoc.ReadabilityStatistics(9) & ": " & objdoc.ReadabilityStatistics(9).value & vbCrLf & "(Ideal values above 60)"
MsgBox objdoc.ReadabilityStatistics(8) & ": " & objdoc.ReadabilityStatistics(8).value & vbCrLf & "(Ideal values above 60)"
End If
Set objdoc = Nothing
Set objInsp = Nothing
End Sub
答案 0 :(得分:2)
您执行的以下代码
Set objdoc = objInsp.WordEditor
给你一个WordDocument
所以现在你有一个WordVBA问题而不是一个OutlookVBA问题。因此,您需要对文档进行更改onchange
事件
我在SO内部和外部获得了很多线程,这证实了这样的事件不存在
http://www.vbaexpress.com/forum/showthread.php?15718-Is-there-a-text-change-event-for-Word
Is there a way to trigger "track changes" through VBA in Excel?
Detecting when data is added to a document, eg. a character or white space
http://www.vbaexpress.com/forum/showthread.php?40690-MS-WORD-2k7-Table-content-change-event
因此,您需要使用现有的内容,即检查电子邮件发送中的内容