Can I position a Duplicate Object Using VBA Code

G

Gary

I duplicated an object, and I can use the move command to position it.

I am able to position an object by its ID by the Cells("PinX") and
Cells("PinY") method. I want to position a duplicated object by positioning
the Selection. Can I do this using a Cells("PinX") and Cells("PinY")??? I
can do this using the move command already.


Thank You,

Gary
 
C

Chris Roth [MVP]

Hi Gary,

This kind of works:

Sub CopySelection()

Dim sel As Visio.Selection
Set sel = Visio.ActiveWindow.Selection

Call ActivePage.Drop(sel, 5, 5)

End Sub

You use the Drop method to essentially duplicate the selection. Only problem
is that Drop wants to return a single Shape. In this case, the drop works,
but Visio complains that the result of the drop is not a single shape, and
that you are thus getting a Nothing as a returned object. Weird, but kind of
makes sense.

Another option would be to do some grouping:

Sub CopySelection2()

Dim shp1 As Visio.Shape
Dim shp2 As Visio.Shape

Dim sel As Visio.Selection
Set sel = Visio.ActiveWindow.Selection

Set shp1 = sel.Group()
Set shp2 = shp1.ContainingPage.Drop(shp1, 5, 5)

shp1.Ungroup
shp2.Ungroup

End Sub



--
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

Top