2
votes

2 Monitor set-up. 1 Active workbook open in the right monitor. I want to have newly opened workbooks open in the left monitor. I found how to do this and it works but if the file opens in "Protected View", it doesn't fire.

If I click to enable editing, there's some screen flicker like it worked but the window ends up still on the right monitor. Subsequently opening the file fires the macro correctly. However, this won't work for me as I'm opening attachments in Outlook.

Any way around this?

This is in the "ThisWorkbook" module of my Personal.XLSB file:

Private WithEvents app As Application


Private Sub Workbook_Open()
    Set app = Application
End Sub


Private Sub app_WorkbookOpen(ByVal Wb As Workbook)
    If Not Win_Toggle = 1 Then Exit Sub

    With app
        .WindowState = xlNormal
        .Left = -500
        .WindowState = xlMaximized
    End With
End Sub

The toggle is of course set to 1..

Ideally, it will fire on open and without me clicking "enable editing".

1

1 Answers

2
votes

The WorkbookOpen event won't fire for workbooks opened in Protected View. You need the ProtectedViewWindowOpen event.

Private Sub app_ProtectedViewWindowOpen(ByVal Pvw As ProtectedViewWindow) 
    If Not Win_Toggle = 1 Then Exit Sub

    With app
        .WindowState = xlNormal
        .Left = -500
        .WindowState = xlMaximized
    End With        
End Sub