我想更改幻灯片中的所有形状边框

问题描述

Dim oSh As Shape

For i =1 To 5

在这里给了 For 循环去寻找每个形状

With oSh
.Fill.Visible = False
.Line.BackColor.RGB = RGB(255,255,0)
Set oSh = nothing
End With
Next i

但是好像不能正常工作

End Sub

解决方法

改变这个:

With oSh
.Fill.Visible = False
.Line.BackColor.RGB = RGB(255,255,0)
Set oSh = Nothing
End With

为此,假设您要使用当前选定的幻灯片:

Sub ChangeTheShapes()
' Make sure you select one or more
' slides (in the thumbnail pane or slide sorter)
' before running this.

    Dim osh As Shape
    Dim oSl As Slide
    
    ' in case a shape doesn't have a fill
    On Error Resume Next
    
    For Each oSl In ActiveWindow.Selection.SlideRange
        For Each osh In oSl.Shapes
            With osh
              .Fill.Visible = False
              .Line.BackColor.RGB = RGB(255,0)
            End With
        Next   ' Shape
    Next 'slide
    
End Sub

你也可以删除你对变量 i 所做的任何事情,因为你没有将它用于任何事情。