Reading a copied shape off the Clipboard with VBA

Started by Visisthebest, February 09, 2021, 02:48:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

So far I've just used Visio selections a lot but not the clipboard yet. For custom copy-pastes it is very handy to be able to read from it.

If the user copies a shape to the clipboard, what is the best way to read the shape object (reference) off the clipboard? (and of course provide the user a message it if it doesn't contain one Visio shape but something else).

Thank you for your help!
Visio 2021 Professional

Paul Herber

Just do a

  thepage.Paste

You can't tell from this what is in the paste buffer, Visio will try to paste whatever is there.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

wapperdude

Visio 2019 Pro

Visisthebest

Thank you unfortunately for just reading the clipboard with VBA in Visio and upon paste 'rejecting' (giving the user a message it is not a Visio shape being pasted) the content of the clipboard if it is not a Visio shape, I understand this is not an easy thing to do.

That it unfortunate but can be solved with a custom copy/paste solution within a Visio document context. I read that reading the clipboard used to be much easier with VB6 but in VBA there's more complexity especially if pasting more than just a string.

Visio 2021 Professional

wapperdude

You've probably seen this, not sure it's helpful, (this level of programming above my paygrade):  https://docs.microsoft.com/en-us/office/vba/access/concepts/windows-api/retrieve-information-from-the-clipboard

Don't have a clue as to how you would test if an object on clipboard is a Visio shape.
Visio 2019 Pro

wapperdude

Visio 2019 Pro

Visisthebest

Thank you Surrogate in the last forum link you shared I saw this link:

http://www.cpearson.com/excel/Clipboard.aspx

That is probably what I need for this super!
Visio 2021 Professional