View Single Post
 
Old 06-04-2017, 03:12 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

There are different types of shapes which could appear in your document. I would assume your document has some shapes that don't have text frames - perhaps they are graphics imported from other programs. You will need to test for those types so you can exclude them from the recolouring. This amended code will stop the macro so you can examine the problem shape and work out what is causing the error. If you can work out what type of shapes you want the code to address/avoid then you can recode the macro to do that.
Code:
Sub EmptyShapes()
  Dim aShp As Shape, aShp2 As Shape
  On Error GoTo ErrCatcher
  For Each aShp In ActiveDocument.Shapes
    If aShp.TextFrame.HasText Then
      aShp.Fill.Visible = False
    ElseIf aShp.Type = msoGroup Then
      For Each aShp2 In aShp.GroupItems
        If aShp2.TextFrame.HasText Then
          aShp2.Fill.Visible = False
        End If
      Next aShp2
    End If
  Next aShp
  Application.ScreenRefresh
  Exit Sub
ErrCatcher:
  aShp.Select
  MsgBox "Error: " & Err.Number & "  " & Err.Description & vbCr & "Shape type: " & aShp.Type
End Sub
Also, what version of Word are you using?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote