View Single Post
 
Old 08-03-2023, 11:40 AM
darkmaster006 darkmaster006 is offline Windows 10 Office 2021
Novice
 
Join Date: Aug 2023
Posts: 10
darkmaster006 is on a distinguished road
Default

Quote:
Originally Posted by Italophile View Post
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
Thank you, yes, this was better than what I could come up with, thank you very much!
Reply With Quote