我特别需要什么指导:
要有指示新邮件撰写中可用的 native VBA 方法,该方法将在任何书面单词/短语(或尽可能频繁)处触发 ,或有关如何创建动态表单属性的 observable 的指南。
目的:
一项可能有趣的 Outlook 功能是在撰写邮件时了解其可读性值。我知道可以通过拼写检查来获得它们,但我想避免进行拼写检查以获得结果的负担 - 我希望看到数字在写邮件时上下波动。
问题:
我有点创建了我需要的功能,但我没有找到一种方法可以在写下每个字时触发它。我假设它会像 WordEditor_Change
, HTMLBody_Change
或类似的东西。它类似于 Worksheet_Change
我们在 Excel 中,可以在编辑 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
最佳答案
您执行的以下代码
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
所以你需要使用你现在拥有的,即检查电子邮件发送的内容
关于vba - Outlook 可以在撰写或回复邮件时触发什么 VBA 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49482684/