Author Topic: copy and paste a shape and get the id of the new shape  (Read 116 times)

0 Members and 1 Guest are viewing this topic.

matthew

  • Jr. Member
  • **
  • Posts: 32
copy and paste a shape and get the id of the new shape
« on: October 29, 2020, 12: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


matthew

  • Jr. Member
  • **
  • Posts: 32
Re: copy and paste a shape and get the id of the new shape
« Reply #1 on: October 30, 2020, 02:19:23 PM »
Managed to work it out, just needed to be more specific with the document I was working with!