-
Can't move to layer; only adds layer instead
I'm trying to move a selected shape from one layer to another. Instead, all I can do is to add the 2nd layer to the existing layers of the shape.
[vba]Sub MoveToLayer()
Dim shp As Shape
Set shp = ActiveWindow.Selection.Item(1)
ActivePage.Layers("Weldments N Trailing End").Add shp, 0
End Sub
[/vba] After running this code, the selected shape is shown as having "multiple layers", including the original layer.
The help for Add in this context reads:
expression.Add(SheetObject, fPresMems)
expression A variable that represents a Layer object.
Name Required/Optional Data Type Description
SheetObject Required (IVSHAPE) The new Shape object added to the Layer object.
fPresMems Required Integer Zero to remove subshapes from any previous layer assignments; non-zero to preserve layer assignments
Visio 2007 on Windows 7, BTW.
-
This has got to be the single clunkiest, stupidest-looking piece of code I've ever been forced to use, but it seems to work:
[vba]Sub MoveToLayer()
Dim strLayer As String
Dim shp As Shape
Set shp = ActiveWindow.Selection.Item(1)
strLayer = """" & ActivePage.Layers("B").Index - 1 & """"
shp.CellsSRC( _
visSectionObject, visRowLayerMem, visLayerMember).FormulaForceU _
= strLayer
End Sub[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules