从可能被分组的文本框、形状等中删除字符串
Delete string from textbox,shapes etc that may be grouped
这将从形状或文本框中删除文本,但不会从分组的文本框或形状中删除文本。
我如何修改下面的代码以满足我的需要?
我想要的是简单地删除字符串 strf
和 "(" & strf & ")"
出现在 ppt 中的任何位置。但这似乎忽略了分组对象。
For Each Sld In PP.Slides
For Each Shp In Sld.Shapes
With Shp
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, "(" & strf & ")", "")
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, strf, "")
Debug.Print Sld.Name, .Name, .TextFrame.TextRange.Text
End With
Next Shp
Next Sld
从 MrExcel MVP here 那里得到了解决方案。
这将循环遍历组中的每个子项目,我基本上想要的。
For Each Sld In PP.Slides
For Each Shp In Sld.Shapes
With Shp
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, "(" & strf & ")", "")
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, strf, "")
Debug.Print Sld.Name, .Name, .TextFrame.TextRange.Text
End With
For Each Shp1 In Shp.GroupItems
With Shp1
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, "(" & strf & ")", "")
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, strf, "")
Debug.Print Sld.Name, .Name, .TextFrame.TextRange.Text
End With
Next
Next Shp
Next Sld
这将从形状或文本框中删除文本,但不会从分组的文本框或形状中删除文本。
我如何修改下面的代码以满足我的需要?
我想要的是简单地删除字符串 strf
和 "(" & strf & ")"
出现在 ppt 中的任何位置。但这似乎忽略了分组对象。
For Each Sld In PP.Slides
For Each Shp In Sld.Shapes
With Shp
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, "(" & strf & ")", "")
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, strf, "")
Debug.Print Sld.Name, .Name, .TextFrame.TextRange.Text
End With
Next Shp
Next Sld
从 MrExcel MVP here 那里得到了解决方案。
这将循环遍历组中的每个子项目,我基本上想要的。
For Each Sld In PP.Slides
For Each Shp In Sld.Shapes
With Shp
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, "(" & strf & ")", "")
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, strf, "")
Debug.Print Sld.Name, .Name, .TextFrame.TextRange.Text
End With
For Each Shp1 In Shp.GroupItems
With Shp1
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, "(" & strf & ")", "")
.TextFrame.TextRange.Text = Replace(.TextFrame.TextRange.Text, strf, "")
Debug.Print Sld.Name, .Name, .TextFrame.TextRange.Text
End With
Next
Next Shp
Next Sld