View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] giancarp@googlemail.com is offline
external usenet poster
 
Posts: 1
Default Problem copying from a hidden worksheet (data is copied, but alsoadditional sheet info)

On 31 Jan, 15:39, Dave Peterson wrote:
So I have a question for you.

Are you pasting just the value or do you want to include formatting?

If you're pasting just values, your code could use the windows clipboard.

Option Explicit
Sub testme()

* * Dim MyDataObj As DataObject
* * Dim myVal As Variant

* * Set MyDataObj = New DataObject

* * myVal = Sheet1.Range("A1").Value
* * MyDataObj.SetText myVal
* * MyDataObj.PutInClipboard

End Sub


Thanks Dave, I didn't know about the DataObject, so it was a useful
post for me.
I am happy to get the values only, but my example was simplified: in
the real application, I need to copy a table from the spreadsheet, so
"myVal" would end up being an array of variants. It seems to me that
MyDataObj.SetText can only work on strings. CPearson's website was
also useful, but didn't mention the case of copying anything different
from a string. Is that be possible?

In any case, thanks for your reply. BTW my system is: "Windows XP
Professional" and Excel 2003 SP2
gc