2013-03-25 51 views
0

Powerpoint 2010如何選擇循環中的每個形狀?

我想選擇循環中的每個新形狀。但並不是所有形狀都在循環中被選中。始終只選擇最後一個形狀。哪裏不對?

謝謝

Private Sub AddShapeRectangleOnSelectedText() 

    Dim oText As TextRange 
    Dim linesCount As Integer 
    Dim myDocument As Slide 
    Dim i As Integer 
    Dim s As Shape 

    ' Get an object reference to the selected text range. 
    Set oText = ActiveWindow.Selection.TextRange 
    Set myDocument = ActiveWindow.View.Slide 
    linesCount = oText.Lines.Count 

    For i = 1 To linesCount 
    Set s = myDocument.Shapes.AddShape(msoShapeRectangle, _ 
    oText.Lines(i).BoundLeft, oText.Lines(i).BoundTop, oText.Lines(i).BoundWidth, oText.Lines(i).BoundHeight) 

    With s 
    .Select 
    .Fill.Visible = msoTrue 
    .Fill.Solid 
    .Fill.ForeColor.RGB = RGB(255, 255, 153) 
    .Fill.Transparency = 0.7 
    .Line.Visible = msoFalse 
    .Line.Transparency = 0# 
    End With 
    Next 

末次

回答

0

Select有一個可選的參數,以指示選擇是否應取代先前的選擇或不...

你可以修改你這樣的代碼

.Select IIf(i = 1, True, False) 
+0

謝謝。這是有幫助的 – Argonist 2013-03-25 22:37:01