P
Paul
I come from a C++ background, and without actually taking VBA, I’m
cobbling together code from the web to change attributes of selected
shapes, lines, and associated text. I’m trying to reconcile the
difference in coding style between the following two code pieces for
changing a line from dashed to solid:
1. From the Web
------------------
Public Sub SelectAllDashed()
Dim shp As Shape
Visio.ActiveWindow.DeselectAll
For Each shp In Visio.ActivePage.Shapes
If shp.OneD Then
If shp.Cells("LinePattern") = 23 Then
shp.Cells("LinePattern") = 1
End If
End If
Next shp
End Sub
2. From Macro Recording
---------------------------
Sub Palette2()
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Line Properties")
Application.ActiveWindow.Page.Shapes.ItemFromID(7).CellsSRC(visSectionObject,
visRowLine, visLinePattern).FormulaU = "1"
Application.EndUndoScope UndoScopeID1, True
End Sub
I understand that there are differences in control flow structure due
to the fact that #1 searches for dashed lines, while #2 just sets a
line pattern. However, the difference between the statements that
actually assigns the line pattern “1” is quite pronounced. Some of it
is due to the fact that “shp” in #1 already has
“Visio.ActivePages.Shapes” implied, but the rest of the line is still
simpler in #1. Is it preferrable to use #1?
Further complicating the deciphering of #2’s pattern assignment line
is the fact that the words don’t match readily with what I see in the
ShapeSheet. Without learning the entire schema of Visio, what is the
best strategy for using Macro Recording to pull out the details that I
might want to use in my own code?
Thanks.
cobbling together code from the web to change attributes of selected
shapes, lines, and associated text. I’m trying to reconcile the
difference in coding style between the following two code pieces for
changing a line from dashed to solid:
1. From the Web
------------------
Public Sub SelectAllDashed()
Dim shp As Shape
Visio.ActiveWindow.DeselectAll
For Each shp In Visio.ActivePage.Shapes
If shp.OneD Then
If shp.Cells("LinePattern") = 23 Then
shp.Cells("LinePattern") = 1
End If
End If
Next shp
End Sub
2. From Macro Recording
---------------------------
Sub Palette2()
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Line Properties")
Application.ActiveWindow.Page.Shapes.ItemFromID(7).CellsSRC(visSectionObject,
visRowLine, visLinePattern).FormulaU = "1"
Application.EndUndoScope UndoScopeID1, True
End Sub
I understand that there are differences in control flow structure due
to the fact that #1 searches for dashed lines, while #2 just sets a
line pattern. However, the difference between the statements that
actually assigns the line pattern “1” is quite pronounced. Some of it
is due to the fact that “shp” in #1 already has
“Visio.ActivePages.Shapes” implied, but the rest of the line is still
simpler in #1. Is it preferrable to use #1?
Further complicating the deciphering of #2’s pattern assignment line
is the fact that the words don’t match readily with what I see in the
ShapeSheet. Without learning the entire schema of Visio, what is the
best strategy for using Macro Recording to pull out the details that I
might want to use in my own code?
Thanks.