【发布时间】:2023-03-08 23:09:01
【问题描述】:
我有自动缩放电子邮件窗口窗格的代码。直到几天前对 MS Outlook 进行了最新更新后,它才有效。
'Install redemption and add "Microsoft Word Object Library" reference and "Redemption Outlook library" reference.
Option Explicit
Dim WithEvents objInspectors As Outlook.Inspectors
Dim WithEvents objOpenInspector As Outlook.Inspector
Dim WithEvents objMailItem As Outlook.MailItem
Dim WithEvents myOlExp As Outlook.Explorer
Dim sExplorer As Object
Dim Document As Object
Dim Msg
Const MsgZoom = 150
Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
Set myOlExp = Application.ActiveExplorer
Set sExplorer = CreateObject("Redemption.SafeExplorer")
End Sub
Private Sub Application_Quit()
Set objOpenInspector = Nothing
Set objInspectors = Nothing
Set objMailItem = Nothing
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class = olMail Then
Set objMailItem = Inspector.CurrentItem
Set objOpenInspector = Inspector
End If
End Sub
Private Sub objOpenInspector_Close()
Set objMailItem = Nothing
End Sub
Private Sub objOpenInspector_Activate()
Dim wdDoc As Word.Document
Set wdDoc = objOpenInspector.WordEditor
wdDoc.Windows(1).Panes(1).View.Zoom.Percentage = MsgZoom
End Sub
Private Sub myOlExp_SelectionChange()
On Error GoTo ErrHandler:
Set Msg = Application.ActiveExplorer.Selection(1)
Application.ActiveExplorer.RemoveFromSelection (Msg)
Application.ActiveExplorer.AddToSelection (Msg)
sExplorer.Item = Application.ActiveExplorer
Set Document = sExplorer.ReadingPane.WordEditor
Document.Windows.Item(1).View.Zoom.Percentage = MsgZoom
Exit Sub
ErrHandler:
Exit Sub
End Sub
我必须单击电子邮件,然后再次单击它才能使自动缩放起作用。过去,我点击了一次电子邮件。
我使用的是 Microsoft Outlook 2016 版本 1805(内部版本 9330.2087)
导致问题的代码段在myOlExp_SelectionChange()。
当我在myOlExp_SelectionChange() 中添加断点并单步执行代码时,自动缩放在调试模式下工作。
【问题讨论】:
-
我刚刚在 Outlook 2016 (16.0.9226.2156) 中对其进行了测试,它可以立即运行。
-
您的机器上安装了 Outlook 2016 的哪个版本和内部版本号?
-
Eugene,我使用的是 Microsoft Outlook 2016 版本 1805(内部版本 9330.2087)
-
看来我需要获取最新更新。让您知道它如何与新版本一起使用:)
-
好的。我正在使用 Outlook 2016 (16.0.9330.2073) x86。它工作正常。尝试在 VBA 编辑器中的调试器 (F5) 下的事件处理程序之外运行代码。你得到相同的结果吗?