LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default MSForms.DataObject Misbehaving

I am trying to swap the contents and formats of two equally sized
ranges. (this is part of a specialised sorting routine).
The obvious way seems to be to use a DataObject to hold the formatted
text while doing the switch, but this appears to be a total failure.
Here is the code, try running it with two different words in cells A1
and B1

Sub test()
Dim A As New MSForms.DataObject
Sheet1.Range("A1").Cut
A.GetFromClipboard
Debug.Print "1 " & A.GetText
Sheet1.Range("A2").Copy Sheet1.Range("A1")
Debug.Print "2 " & A.GetText
B.PutInClipboard
Sheet1.Range("A2").PasteSpecial
End Sub

See how the Copy line alters the text property of A? Surely that isn't
right.
To compound matters, the PasteSpecial line crashes my Excel (2003) by
creating a blank text frame, and disabling all the menus....

Perhaps the DataObject is the wrong class to hold formatted range
data? Any suggestions how to swap two ranges while keeping the
formatting? Currently I am thinking of creating a temporary worksheet
and hiding it, but that seems very untidy.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error using DataObject to get clipboard data stocktsi Excel Discussion (Misc queries) 4 April 29th 09 02:54 PM
DataObject Sheila Excel Programming 1 October 20th 06 08:20 PM
DataObject in BeforeDragOver has no format John Shell Excel Programming 2 September 1st 06 09:51 PM
DataObject and cliboard D.2 Excel Programming 5 January 22nd 05 08:00 PM
Can't Dim As DataObject?? Ed[_9_] Excel Programming 3 January 12th 04 09:35 PM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"