Quote:
Originally Posted by Italophile
I’m pretty sure you’ll find that the page color has only been set to make the text shading visible. Kinda hard to see white shading against a white background.
|
Indeed. Although, for a fact, I am using that page colour. It's easier on the eyes than the white. Thank you for all the help!
Quote:
Originally Posted by vivka
Italophile, thank you for clearing up the misunderstanding. My n-th try:
Code:
Sub Test_Nth()
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
End Sub
|
Wow, this works amazingly! Thank you very much for all the help, too!
Just in case, I added:
Selection.HomeKey Unit:=wdStory
(that is, Ctrl+Home)
so that the cursor ends up in the beginning of the document. With that added, this works flawlessly.
Full code, in case anyone wants it:
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