Delete User-defined Cells in a Shapesheet Row

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
 
C

Chris Roth [MVP]

Hi Philip,

When you type DeleteRow in VBA, you should see that you need two arguments:
a section index and a row index.

Try something like this:

If shp.CellExists("User.CPMSetList", Visio.VisExistsFlags.visExistsAnywhere)
Then
Dim c as Visio.Cell
Set c = shp.Cells("User.CPMSetList")
shp.DeleteRow( c.Section, c.Row )
End If

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 

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

Delete User Defined Cells 5

Top