Thread: [Solved] vba control of shading
View Single Post
 
Old 04-08-2021, 05:40 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,641
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

I thought that might be the case. It probably doesn't matter so much as long as there is at least one full Word (and trailing space) on either side of that undefined shading to capture both values that can then be used by the Find code. This modification excludes undefined and duplicate values
Code:
Sub FindAllShades()
  Dim aWord As Range, lPatt As Long, sList As String
  For Each aWord In ActiveDocument.Words
    If lPatt <> aWord.Font.Shading.BackgroundPatternColor Then
      lPatt = aWord.Font.Shading.BackgroundPatternColor
      If Not sList Like "*" & lPatt & "*" And lPatt <> 9999999 Then
        sList = sList & lPatt & "|"
      End If
    End If
  Next aWord
  Debug.Print sList
End Sub
I'm not exactly sure what the OP is trying to do with the 'associate comments/notes' but I would expect that iterating through the comments (as you suggested) would be a more logical thing to do than trying to work through the shading changes.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote