PDA

View Full Version : How do I preserve the user's Clipboard while he's accessing my form?



xltrader100
08-17-2008, 05:07 PM
Users of a program often don't want their Clipboard messed with while they're interacting with a userform, but the form still needs to copy things internally to perform it's function. I found some halfhearted solutions that involve saving the Clipboard contents to a file, or to a cell, or to internal memory and then restoring afterwards, but that seems totally unworkable to me because how do you know when "afterwards" is. It would have to be after every keystroke or mouse click to be totally transparent to the user.

I thought the Office Clipboard might be a way out, but everything I can find on that says it's not accessible by VBA. So, how do other people do it? Or is it not possible.

Jan Karel Pieterse
08-17-2008, 09:44 PM
Could you tell me why you need to use the clipboard in the userform's code? You can access all information you need directly from its object model.

xltrader100
08-17-2008, 11:40 PM
Hi Jan, I'm using Stephen Bullen's PastePicture, which requires that the picture be on the clipboard to start with.

Jan Karel Pieterse
08-18-2008, 12:45 AM
OK, gotcha.
I guess the "half-hearted" solution IS the only alternative. I'd restore the clipboard immediately after issuing your last pastepicture command, since your used might have put something on the clipboard he wants to paste into the form itself.