ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Weird clipboard behavior (https://www.excelbanter.com/excel-programming/333804-weird-clipboard-behavior.html)

Josh Sale

Weird clipboard behavior
 
I'm investigating some weird clipboard behavior and came across the
following observation. If I bring up two copies of XL2003 and paste the
following macro into both of them:

Sub main()
Range("a1").Copy
MsgBox "copied " & Range("a1").Value
Range("b1").PasteSpecial xlPasteAll
End Sub

In the first copy of Excel, I type the value "book1" into cell A1 of the
active worksheet. In the second copy of Excel, I type the value "book2"
into cell A1 of the active worksheet.

I then run main on the first copy of Excel. When the MsgBox comes up I run
main in the second copy of Excel. I then click OK on the MsgBox associated
with the second copy of Excel. Cell B1 gets the value "book2" as expected.

If I then click OK on the MsgBox associated with the first copy of Excel,
cell B1 gets no value! Instead it gets a shape object that has a value of
"book2"!!

Very weird.

Does anybody know why the second PasteSpecial works differently?

TIA,

josh




All times are GMT +1. The time now is 06:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com