MSForms.DataObject Misbehaving

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • Tricky Scenario finding days/months/years!
    ... Unfortunately that only formats the date that i want to search with with ... I want to use 01/03/04 and see if it is withing any of my ranges, ... perhaps a harder solution that at first percieved. ...
    (microsoft.public.excel.misc)
  • Re: multiple date params
    ... and not using ambiguous date formats. ... I want to select the following date ranges from a datetime column: ... > I couldnt seem to make the BETWEEN operator work on dates... ...
    (microsoft.public.sqlserver.programming)
  • RE: Pivot tables using multiple tables
    ... The tables do not have the same formats or ranges. ... "Jacob Skaria" wrote: ... I want to show the Tech Name (Which is a field in both ...
    (microsoft.public.excel.programming)
  • Re: Matching number formats
    ... >Thanks, Ron. ... >I did accomplish my goal, but it took a long time. ... >I formatted both ranges as text and then I had to go down the entire list ... >these formats. ...
    (microsoft.public.excel.misc)
  • Re: What is fastest? "If .LineStyle <> xlContinuous ..." or ".LineStyle = xlContinuous" ??
    ... down to optimum ranges to restore. ... Read cell formats is significantly faster than Write formats. ... End Sub ... if .LineStyle xlContinuous then ...
    (microsoft.public.excel.programming)