copy to Clipboard vba problems

utuber

New Member
Joined
Oct 19, 2009
Messages
34
Hello all,
I have a problem when I'm using a macro to copy a cell contents then I use ctrl+v to paste to a webform or to another cell in excel. The macro functions perfectly until I put the computer into either "sleep" or "Hibernate". Upon waking I find ctrl+v pastes nothing into the webform, nothing into NotePad and pasting back into excel the result is 2x question marks in a square.


Another thing I found was that if I open the Clipboard I see the values arriving there and if I left click the value in the Clipboard list I can then paste to excel, notepad and webform as many times as I like until I use the macro again to copy another cell value then I'm back to the problem pasting as explained above.


I have found a solution which is to change the Region and re-log back in. This of course is not suitable and defeats the sleep/hibernate advantage.


I'm running Win10 x64 and Excel 2013


Here is the macro I am using.
----------------------------------
Sub CopyToClipboard()
'Macro to copy cell value to clipboard to be pasted elewhere

Dim clipboard As MSForms.DataObject
Dim strSample As String


Set clipboard = New MSForms.DataObject

strSample = ActiveCell.Value 'Copies Active Cell Value to insert in Clipboard

clipboard.SetText strSample
clipboard.PutInClipboard

End Sub
----------------------------------
Any help with this problem would be very much appreciated.
Thanks for reading
Peter
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hello again. I have run the spreadsheet on another computer with Win7 and the problem does not exist. Seems only a problem on Win10 OS...

I'm confused..
 
Upvote 0
Thank you so much shg. I was sure someone much more skilled than myself would come up with a solution to my latest Excel VBA problem.

I didn't find RoryA posting but Chandoo.org's fix using Windows API seems to be working well.

Thanks once again for your help

Peter
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top