View Full Version : VBA to clear any shape border on all slides
rwc1023
06-08-2021, 12:21 PM
Hello - i need a simple VBA to clear shape borders on all slides. the one i have below is not really working...i think the shapeborder.clear is not right.
any ideas the right fix should be? thank you!:hi:
Sub RemoveShapeBorder()
Dim sld As Slide
For Each sld In ActivePresentation.Slides
sld.ShapeBorder.Clear
Next
End Sub
Paul_Hossler
06-08-2021, 04:01 PM
Option Explicit
Sub ClearBorders()
Dim oSlide As Slide
Dim oShape As Shape, oShape2 As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoGroup Then
oShape.Line.Weight = 0
For Each oShape2 In oShape.GroupItems
oShape2.Line.Weight = 0
Next
Else
oShape.Line.Weight = 0
End If
Next
Next
End Sub
John Wilson
06-08-2021, 09:56 PM
I would use
Sub ClearBorders()
Dim oSlide As Slide
Dim oShape As Shape, oShape2 As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoGroup Then
oShape.Line.Visible = False
For Each oShape2 In oShape.GroupItems
oShape2.Line.Visible = msoFalse
Next
Else
oShape.Line.Visible = False
End If
Next
Next
End Sub
Paul's code should work but can have unexpected results with placeholders
rwc1023
06-09-2021, 05:24 AM
Thank you John.
I got a run time error - the specified value is out of range. any idea how to fix this??
thank you!
I would use
Sub ClearBorders()
Dim oSlide As Slide
Dim oShape As Shape, oShape2 As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoGroup Then
oShape.Line.Visible = False
For Each oShape2 In oShape.GroupItems
oShape2.Line.Visible = msoFalse
Next
Else
oShape.Line.Visible = False
End If
Next
Next
End Sub
Paul's code should work but can have unexpected results with placeholders
John Wilson
06-09-2021, 05:43 AM
Thank you John.
I got a run time error - the specified value is out of range. any idea how to fix this??
thank you!
Most likely reason is you have a shape that cannot have the line set, maybe an ActiveX shape or a Table?
Try ignoring the error like this
Sub ClearBorders()
Dim oSlide As Slide
Dim oShape As Shape, oShape2 As Shape
On Error Resume Next
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoGroup Then
oShape.Line.Visible = False
For Each oShape2 In oShape.GroupItems
oShape2.Line.Visible = msoFalse
Next
Else
oShape.Line.Visible = False
End If
Next
Next
End Sub
Paul_Hossler
06-09-2021, 07:56 AM
John --
1. I added On Error to handle Tables and such
2. Went with .Visible = msoFalse
3. Add recursion in case a Group contained other Groups
4. But .Visible = msoFalse seems to change Title placeholders to top left
John Wilson
06-09-2021, 09:00 AM
Not sure why Paul (yet) but it doesn't happen if I recreate the title slide OR reapply the Title layout to the first slide.
Paul_Hossler
06-09-2021, 11:31 AM
More PP wierdness ??
The Before and After (including the PPTM After)
But didn't do it to Slide 2
28590
28591
John Wilson
06-09-2021, 12:22 PM
More PP wierdness ??
The Before and After (including the PPTM After)
But didn't do it to Slide 2
28590
28591
Very strange. Even looking through the XML I can see nothing strange about the slide that misbehaves.
Paul_Hossler
06-09-2021, 12:55 PM
Slide 3 Title does the same thing, but Slide 2 doesn't
I didn't see any common thread
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.