Attribute VB_Name = "WordMacroX_22_02_2023" Private Declare PtrSafe Function CustomTimeOffMsgBox Lib "user32" Alias "MessageBoxTimeoutA" ( _ ByVal xHwnd As LongPtr, _ ByVal xText As String, _ ByVal xCaption As String, _ ByVal xMsgBoxStyle As VbMsgBoxStyle, _ ByVal xwlange As Long, _ ByVal xTimeOut As Long) _ As Long 'See SOURCE below Sub WordX_22_02_2023() 'Macro X for Word - to Close Active Window Word file>> Add to QAT with "X" symbol 'SOURCE: james.martin@birmingham.gov.uk ScreenUpdating = False Dim ActiveDocument As Object Dim ProtectedViewWindow As Object 'If a file is Protected View, Make it Editable If Application.ProtectedViewWindows.Count > 0 Then 'if protected view file is not active window On Error Resume Next Application.ActiveProtectedViewWindow.Edit End If 'If Macro X is pressed in error with no file in Open Word App On Error GoTo ExitSub ''Resume Next 'if active window has a document close it Application.ActiveDocument.Close 'MsgBox appears briefly for 300 thousandths of a second, and Closes so Macro L detects the Macro X usage. 'SOURCE: https://wwwextendoffice.com/documents/excel/3836-excel-message-box-timer-timeout.html Call CustomTimeOffMsgBox(0, "", "WORD MACRO X - Close Active Window", vbInformation, 0, 300) ExitSub: ScreenUpdating = True Exit Sub End Sub 'Other methods to popup a message for Macro L: 'https://stackoverflow.com/questions/4274103/display-a-message-box-with-a-timeout-value#35139233 'This is needed so that triggered Macros show up in the Macro L Log 13/02/2023 'need to recode if poss to 0.1 second. Couldn't manage this 18/02/2022 'Call CreateObject("WScript.Shell").popup("", 1, "WORD MACRO C - Compress Images to 150ppi", vbOKOnly) 'solution? https://stackoverflow.com/questions/40631009/display-popup-for-a-time-period-in-excel