首页 > 代码库 > VBA改变visio图形内控件内容和颜色
VBA改变visio图形内控件内容和颜色
主要利用visio开发者模式,在没有开发帮助文档的情况下,实现对visio文件的处理
Sub Macro3()
‘Enable diagram services
Dim DiagramServices As Integer
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150
Application.ActiveWindow.SelectAll
‘Restore diagram services
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("填充颜色")
For Each ItemFrom In Application.ActiveWindow.Page.Shapes
Set vsoCharacters = ItemFrom
vsoCharacters.Characters.Text = "okokokokokokokok"
vsoCharacters.CellsSRC(visSectionObject, visRowFill, visFillForegnd).FormulaU = "THEMEGUARD(RGB(255,0,0))"
vsoCharacters.CellsSRC(visSectionObject, visRowFill, visFillBkgnd).FormulaU = "THEMEGUARD(SHADE(FillForegnd,LUMDIFF(THEMEVAL(""FillColor""),THEMEVAL(""FillColor2""))))"
vsoCharacters.CellsSRC(visSectionObject, visRowGradientProperties, visFillGradientEnabled).FormulaU = "FALSE"
Next
Application.EndUndoScope UndoScopeID1, True
End Sub
VBA改变visio图形内控件内容和颜色