addRow + Position in Actions Section isn't working

J

Josef Meile

Hi,

I'm trying to add a new Action to some shapes in a visio drawing. The
problem is
that I wan't to add it at position 0 (zero) of the Actions section, but it
is always
added at the last position.

Here is what I'm doing:

Sub AddShapeActions()
Dim vsoShape As Shape
Dim action As String
Dim caption As String
Dim icon As String
Dim propName As String
Dim docName As String
Dim vsoDocument As Document
Dim vsoPage As Page
Dim masterNameParts() As String
Dim masterName As String

docName = "Diagramm.vsd"
action = "RUNADDONWARGS(""EVAShape"",""/action=modifyplcid"")"
icon = """2512"""
caption = """Edit PLC ID"""
propName = "ModifyPlcID"
Set vsoDocument = Application.Documents(docName)
For Each vsoPage In vsoDocument.Pages
For Each vsoShape In vsoPage.Shapes
If (Not vsoShape.Master Is Nothing) Then
masterNameParts = Split(vsoShape.Master.NameU, ".")
masterName = masterNameParts(0)
If (masterName <> "Information Flow") And _
(masterName <> "Material Flow") And _
(masterName <> "Energy Flow") Then
AddShapeAction vsoShape, propName, caption, 0, action,
icon
End If
End If
Next
Next
End Sub

Sub AddShapeAction(vsoShape As Shape, propName As String, caption As String, _
rowPos As Integer, action As String, icon As String)
If (Not vsoShape.CellExistsU("Actions." + propName, 0)) Then
'This is confusing, after calling addRow, rowPos won't have the same
value
'Shouldn't it return the value entered to the function?
rowPos = vsoShape.AddRow visSectionAction, rowPos, 0
vsoShape.CellsSRC(visSectionAction, rowPos, visActionMenu).FormulaU
= caption
vsoShape.CellsSRC(visSectionAction, rowPos,
visActionAction).FormulaU = action
vsoShape.CellsSRC(visSectionAction, rowPos,
visActionButtonFace).FormulaU = icon
vsoShape.CellsSRC(visSectionAction, rowPos, visActionMenu).RowNameU
= propName
End If
End Sub


What's wrong with that?

Regards
Josef
 
J

JuneTheSecond

I think you are not wrong. Even if you added row by hand, you could just add
row to the last row.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top