View Single Post
 
Old 08-03-2023, 02:10 AM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 555
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

It is very rare that you need to select anything when using VBA code. Here is your routine rewritten to avoid selecting the text.

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)
    With ActiveDocument.Background.Fill
        .ForeColor.ObjectThe meColor = wdThemeColorAccent6
        .ForeColor.TintAndSh ade = 0.6
        .Visible = msoTrue
        .Solid
    End With
    ' Turn option 'Show background colors and images in Display view' on
    ActiveWindow.View.DisplayBackgrounds = True
    ' Select all text and change font to black colour
    ActiveDocument.Content.Font.Color = wdColorBlack
End Sub
Reply With Quote