Disable paste for images

M

MarkN

Hello,

I am regularly sent massive Word documents where images have been pasted
into the document. Is it possible to disable the paste command if someone
tries to paste an image?
 
J

Jezebel

If you write a macro called EditPaste it will run in place of the built-in
command. However it's not so easy to check what's in the clipboard, to
distinguish between pasting text and pasting images: you'll need to read up
on the API calls for the purpose. Or write a VB function (as opposed to
VBA) - VB has access to the ClipBoard object.

In any case, how will this help you with documents that already contain
images?
 
M

MarkN

Thanks for getting back to me,

I am not really VBA (or VB) literate but can 'hack' with the best of them. I
just like to know something is possible before I start.

To answer your question, this will not help me with existing documents, but
most of these documents are produced using a selection of templates. I was
thinking that if I added a macro to the templates that stopped the paste
command from working when an image was to be pasted and also included a
message box "paste won't work, use Insert Picture" then future problems would
be solved.

Does that sound like it might work?
--
Thanks again,
MarkN


Jezebel said:
If you write a macro called EditPaste it will run in place of the built-in
command. However it's not so easy to check what's in the clipboard, to
distinguish between pasting text and pasting images: you'll need to read up
on the API calls for the purpose. Or write a VB function (as opposed to
VBA) - VB has access to the ClipBoard object.

In any case, how will this help you with documents that already contain
images?
 
J

Jezebel

I'm not sure what you see as the difference between a picture pasted from
the clipboard as opposed to one inserted using Insert > Picture. If the
copied picture is a simple graphic, the result is the same either way.
Unless you have in mind that the pictures should be linked rather than
embedded? Or are you trying to prevent the pictures being inserted as
objects (ie with all the baggage of an embedded application)?

Whatever, intercepting the Paste command and trying to work out what the
user is doing is tricky. You could intercept EditPaste, count the number of
pictures in the document, let them paste whatever they want, then check if
the number of pictures has gone up. If so, Undo, and display your message.

Another approach would be to check the document when it is saved: "This
document has too many pictures.... please fix".

However, I would recommend against all of this. The effort of trying to
support code running on other people's computers, plus fielding their calls
when things go wrong (and believe me, you'll get blamed for *everything* ...
"my computer's been totally stuffed since Mark installed that f*g macro...")
will almost certainly be more than dealing with obese documents.



MarkN said:
Thanks for getting back to me,

I am not really VBA (or VB) literate but can 'hack' with the best of them.
I
just like to know something is possible before I start.

To answer your question, this will not help me with existing documents,
but
most of these documents are produced using a selection of templates. I was
thinking that if I added a macro to the templates that stopped the paste
command from working when an image was to be pasted and also included a
message box "paste won't work, use Insert Picture" then future problems
would
be solved.

Does that sound like it might work?
 

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