I'm trying to save and close all open Word files (to start I only target one of them).
The macro I made works when ran from Word (clicking "Execute"), but it won't run when called from the command line with this:
winword.exe /n /mMacro3
Operative system: Windows 11
Word version: 2019
Word opens and says that "the macros of this project have been disabled".
I have tried using a different target file and restarting Word.
The target file is "Doc2.docm".
I think it is available in "Normal.dotm" because it appears when I select this option in the macro menu.
In macro settings, all macros are allowed and also checked the "Trust VBA project DOM" (translated) option just in case.
I don't have the option some people in forums have of a "Security" section (not tab) in the first tab of the file's properties in the file explorer with the option to unblock the file.
Developer->Protect->Restrict editing's options are completely off.
The macro file:
Public Sub Macro3()
'
' Macro3 Macro
'
'
Dim doc As Document
Dim docName As String
docName = "Doc2.docm"
For Each doc In Documents
If doc.Name = docName Then
doc.Save
doc.Close
End If
Next doc
MsgBox "The ''" & docName & "'' document was not founr.", vbExclamation
End Sub
What am I doing wrong? Thank you.