[英]Powerpoint - VBA - Slide status
我希望你做得很好。 我有點卡在宏腳本上,我想執行以下操作
這是為插入形狀而編寫的小宏代碼
Sub TBU()
Dim oSh As Shape
Set oSh = ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 902, 5, 47, 27)
With oSh
With .TextFrame.TextRange
.Text = "[TBU]"
With .Font
.name = "Arial"
.Size = 12
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color = RGB(255, 0, 0)
End With
End With
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 0)
.Fill.Solid
End With
End With
End Sub
僅當具有相同屬性的矩形已經存在但卡在該矩形上時,我才嘗試刪除活動幻燈片中的形狀。
有人有想法嗎?
親切的問候, 納克索斯
我認為查找要刪除的任何形狀的最佳方法是遍歷當前幻燈片中的所有形狀,並調用 function 來檢查給定的形狀是否符合您的標准。
它看起來像這樣
For Each sh in ActiveWindow.View.Slide.Shapes
If ShouldBeDeleted(sh) Then
sh.Delete
End If
Next
'...
Function ShouldBeDeleted(sh as Shape) as Boolean
ShouldBeDeleted = False
'Repeat this IF structure for each criteria.
If sh.Fill.Visible <> msoTrue Then
ShouldBeDeleted = True
Exit Function
End If
If Not sh.HasTextFrame Then
ShouldBeDeleted = True
Exit Function
End If
'... keep repeating these if structures.
End Function
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.