Delete User Defined Cells

P

PPL

Hi,
I'm no VBA expert but I'm trying to write a VBA script that selects drawing
objects by layer and cycles through the selected drawing objects and
deletes User-defined Cells i.e. Row: User.CPMSetList.

I'm getting error "argument not optional" @ the line:
Application.ActiveWindow.Shape.DeleteRow UserCPMSetList

This is the code I'm using. Can anyone please tell me where I'm going wrong?

Sub Remove()
Dim myShape As Shape
Dim index As Integer
'I'm not sure how to Dimension the next line - but it does seem to pass
Set vsoSelection1 =
Application.ActiveWindow.Page.CreateSelection(visSelTypeByLayer,visSelModeSkipSuper,
"Off-Page Reference;Process;Flowchart")

Application.ActiveWindow.Selection = vsoSelection1

For index = 1 To ActiveWindow.Selection.Count
Set myShape = ActiveWindow.Selection.Item(index)
Application.ActiveWindow.Shape.DeleteRow UserCPMSetList ' This line errors
"argument not optional"
Next index
End Sub

Any suggestions would be much appreciated
TIA
Philip
PS:
I'm sorry if I've not follwed NG etiquette. I posted & deleted this message
earlier to the visio.developer.vba group. Not sure if Outlook Express really
does delete it. though?
 
P

Paul Herber

Hi,
I'm no VBA expert but I'm trying to write a VBA script that selects drawing
objects by layer and cycles through the selected drawing objects and
deletes User-defined Cells i.e. Row: User.CPMSetList.

I'm getting error "argument not optional" @ the line:
Application.ActiveWindow.Shape.DeleteRow UserCPMSetList

You need two parameters section name and row. You need visSectionUser
 
P

PPL

Hi Paul,
Thank you for your reply,
Could you please expand on the use the parameters visSectionUser
thanks
Philip
 
P

Paul Herber

Application.ActiveWindow.Shape.DeleteRow(visSectionUser,
UserCPMSetList)


Hi Paul,
Thank you for your reply,
Could you please expand on the use the parameters visSectionUser
thanks
Philip
 
J

John

Hello Philip,

If you have a look at the DeleteRow method in Help, you'll see it takes two
parameters; the first is the row's section name and the second is the row
itself as Paul suggests (both of these should be integers or evalute to an
integer.

In your case we're assuming that the row is called "UserCPMSetList" and that
therefore it comes from the User-defined cells section. The visio constant
for this section is visSectionUser and this evalutes to 242, which is the
section index.

The above should solve the "argument not optional" error, but I think you'll
still need to identify the row index first, so have a go with the slightly
amended code below;

Sub Remove()
Dim myShape As Shape
Dim index As Integer
Dim sel As Selection
Dim iRow As Integer

Set sel = Application.ActivePage.CreateSelection(visSelTypeByLayer, _
visSelModeSkipSuper, "Off-Page Reference;Process;Flowchart")

For index = 1 To sel.Count
Set myShape = sel.Item(index)
If myShape.CellExists("User.CPMSetList", False) = True Then
iRow = myShape.Cells("User.CPMSetList").Row
myShape.DeleteRow visSectionUser, iRow
End If
Next index
End Sub


Best regards

John


Assuming
PPL said:
Hi Paul,
Thank you for your reply,
Could you please expand on the use the parameters visSectionUser
thanks
Philip
 
P

PPL

Thank you Paul & John for your replies.
John: I very much appreciate your comprehensive resonse. I really feel that
I have a much better understanding of what's going on
Really great job. Thank you again.
Best regards
Philip


John said:
Hello Philip,

If you have a look at the DeleteRow method in Help, you'll see it takes
two parameters; the first is the row's section name and the second is the
row itself as Paul suggests (both of these should be integers or evalute
to an integer.

In your case we're assuming that the row is called "UserCPMSetList" and
that therefore it comes from the User-defined cells section. The visio
constant for this section is visSectionUser and this evalutes to 242,
which is the section index.

The above should solve the "argument not optional" error, but I think
you'll still need to identify the row index first, so have a go with the
slightly amended code below;

Sub Remove()
Dim myShape As Shape
Dim index As Integer
Dim sel As Selection
Dim iRow As Integer

Set sel = Application.ActivePage.CreateSelection(visSelTypeByLayer, _
visSelModeSkipSuper, "Off-Page Reference;Process;Flowchart")

For index = 1 To sel.Count
Set myShape = sel.Item(index)
If myShape.CellExists("User.CPMSetList", False) = True Then
iRow = myShape.Cells("User.CPMSetList").Row
myShape.DeleteRow visSectionUser, iRow
End If
Next index
End Sub


Best regards

John


Assuming
 

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

Similar Threads


Top