I have code that auto-zooms the email window pane. It worked until a few days ago after the latest update was made to 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
I have to click on the email, then click it again to get the auto-zoom to work. In the past, I clicked on the email once.
I am using Microsoft Outlook 2016 version 1805 (Build 9330.2087)
The code section that cause the problem is in myOlExp_SelectionChange()
.
Auto-zooming works in debugging mode when I add a breakpoint in myOlExp_SelectionChange()
and step through the code.