Visio Guy

Visio Discussions => General Visio => Topic started by: matthew on October 29, 2020, 05:47:59 PM

Title: copy and paste a shape and get the id of the new shape
Post by: matthew on October 29, 2020, 05:47:59 PM
Hi,
I'm trying to copy and paste a shape and then get the id of the new shape. I was using this code:
    ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(1245), visSelect
    Application.ActiveWindow.Selection.Copy
    Application.ActiveWindow.Page.Paste
    shpid = Application.ActiveWindow.Selection(1).ID
which used to work but now that I've made some changes on how the app works (the app has 2 files open when I run this code) I'm getting a 'selection invalid' run time error on the last line.
The object is still copied and pasted as expected its just that the line 'shpid = Application.ActiveWindow.Selection(1).ID' doesn't work now.
Where am I going wrong?
many thanks
Matthew

Title: Re: copy and paste a shape and get the id of the new shape
Post by: matthew on October 30, 2020, 07:19:23 PM
Managed to work it out, just needed to be more specific with the document I was working with!