Hello there! So, I have a quite long AutoOpen macro running, which does many things: it changes the font to black, it erases fill backgrounds, it makes it possible to set the document background automatically to another colour in already created documents, etc. This is the code:
Code:
Sub AutoOpen()
'
' AutoOpen Macro
'
' This macro opens itself (AutoOpen) automatically with every Word document that's opened normally
' Choose background colour (light green 2)
ActiveDocument.Background.Fill.ForeColor.ObjectThemeColor = wdThemeColorAccent6
ActiveDocument.Background.Fill.ForeColor.TintAndShade = 0.6
ActiveDocument.Background.Fill.Visible = msoTrue
ActiveDocument.Background.Fill.Solid
' Turn option 'Show background colors and images in Display view' on
ActiveWindow.View.DisplayBackgrounds = True
' Change all text font to black colour
ActiveDocument.Content.Font.Color = wdColorBlack
' Change all text and change "fill shading" background to no colour https://www.msofficeforums.com/word-vba/51216-change-fill-text-colour-colour.html
With ActiveDocument.Content.ParagraphFormat
.Shading.Texture = wdTextureNone
.Shading.ForegroundPatternColor = wdColorAutomatic
.Shading.BackgroundPatternColor = wdColorAutomatic
End With
' Change all paragraphs with fill to no fill (from https://www.msofficeforums.com/word-vba/51216-change-fill-text-colour-colour.html)
Application.ScreenUpdating = False
'If the selection includes tables, error 4605 will be returned.
'Thus an error handler is needed:
On Error Resume Next
For Each oPara In ActiveDocument.Range.Paragraphs
oPara.Range.Select
Selection.End = Selection.End - 1
Selection.Shading.BackgroundPatternColor = wdColorAutomatic
Next oPara
Application.ScreenUpdating = True
Selection.HomeKey Unit:=wdStory
End Sub
Now, when I open a file with "Protected View", an error appears before I can even "Enable Editing". This is the error:

Run-time error '4288': The command is not available because no document is open.
I believe this error appears because the document has not been enable for editing (and cannot be). Therefore, to make this automatic, I'd like to add a code that enables editing in any document opened with the AutoOpen macro; the code would go first, so that the rest of the code would be able to run.

Protected View.

Error in the code (first line, cannot run).