由于我的一个Visio项目的时间紧迫,我需要查看所有页面中所有形状的特定字符(将其命名为“&”),然后更改后面的n个字符的颜色,这样我写了一个类似跟随的代码,但它没有经历一个文本块中的所有事件,在它击中第一个循环退出后...我只是需要帮助来解决它我的思想现在有点冷冻...对不起,如果我的问题很愚蠢
Sub test()
Dim PageObj As Visio.Page
Dim shpsObj As Visio.Shapes
Dim shpObj As Visio.Shape
Dim oShpChar As Visio.Characters
Set PageObj = ActivePage
Set shpsObj = PageObj.Shapes
For Each shpObj In shpsObj
'Dim iLength As Integer
Dim iBeginOffset As Integer, iEndOffset As Integer
Set oShpChar = shpObj.Characters
Do
iBeginOffset = InStr(oShpChar.Text, "&test")
'If iBeginOffset = 0 Then Exit Do ' # Not found -> end the loop
iEndOffset = iBeginOffset + 3
oShpChar.Begin = iBeginOffset
oShpChar.End = iEndOffset
oShpChar.CharProps(visCharacterColor) = 9
oShpChar.Begin = oShpChar.Begin + 1
oShpChar.End = oShpChar.CharCount
Loop While (iEndOffset < oShpChar.CharCount)
Next
End Sub
我刚刚将它标记为Excel,因为总体概念是相同的......