1
由于我的某个项目使用Visio的时间很紧,我需要查看所有页面中某些字符的所有形状(将其命名为“&”),然后在它后面改变n个字符的颜色,所以我写了一个类似于下面的代码,但它并没有经过一个文本块中的所有事件,它碰到第一个循环后退出......我只需要帮助来解决它我的想法现在是种冻结...如果我的问题是愚蠢的遗憾在Visio中查找某个字符并重新格式化以下文本
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也因为整个概念是相同的......