PDA

View Full Version : Solved: Text Box Data to be Copied:



asingh
01-04-2006, 10:22 AM
Hi,
i have a text box on my excell sheet. I want to copy the contents to my clipboard. I am trying the following but it is not working...nothing comes onto the clipboard

Sheet1.TextBoxDataDsply.Enabled = True

Sheet1.TextBoxDataDsply.SelStart = 0
Sheet1.TextBoxDataDsply.SelLength = 100
Sheet1.TextBoxDataDsply.Copy

mdmackillop
01-04-2006, 11:39 AM
Hi,

Have a look at PutInClipboard in the VB Help

Regards

MD

Dim MyData As DataObject
Sub TestClip()
Set MyData = New DataObject
ActiveSheet.Shapes("TextBoxDataDsply").Select
MyData.SetText Selection.Text
MyData.PutInClipboard
[A1].Select
ActiveSheet.Paste
End Sub

asingh
01-04-2006, 03:55 PM
Hi,
I tried the above mentioned I get an "object does not support this property or method" [run time error '438'] at the lines :

MyData.SetText Selection.Text
MyData.PutInClipboard


thanks

asingh

mdmackillop
01-04-2006, 04:06 PM
Try with the following references

asingh
01-04-2006, 05:23 PM
I checked out the references on my system...they are all selected same as the screenshot..the only differnce is: the object libraries that I have on my system are version 9.0. The screen shot showed version 11. I dont think this should make a difference....



thanks

asingh

asingh
01-06-2006, 04:17 PM
could some one help me with the above mentioned...still not being able to copy data to the clipboard..even when my references are all correct.........!



thanks

asingh

mdmackillop
01-06-2006, 04:19 PM
What version of Excel are you running?

asingh
01-06-2006, 05:15 PM
I am using MS - Excell 2000 9.0.6926 SP -3 ; windows 2000 professional - service pack 4

regards

asingh

mdmackillop
01-06-2006, 05:49 PM
I can try that tomorrow. Meantime here is my test sheet.

asingh
01-07-2006, 09:26 AM
i tried the above mentioned on a XP - Service Pack 2 with MS - Excell 2003 (11.5612.5606) , and it worked perfectly fine...I was able to copy data to the clopboard...but I need it to work on the 2000 pro set up..with excel 2000...it is still not working on that platform...! Any ideas,,>>



thanks

asingh

mdmackillop
01-09-2006, 11:36 AM
Hi asingh,
I tried my attachment at work. Office 2000, Win XP and it ran as before. References as below. I don't know what else to suggest.
Regards
MD

asingh
01-10-2006, 09:45 AM
Ok...I finally got...

The text box I was using to retrieve data onto my clipboard was the text box that is in the FORMS for VBA in excell. If I use the text box that is normally available with ms - excell [not the forms component] then the copy - to - clipboard method ..works PERFECT, as mentioned above irrespective of the OS or references used....! Thanks MD for the solution. :))


thanks and regards
ASingh

asingh
01-17-2006, 08:53 AM
though this thread was solved...using a shape as the container to store the data in..I also came up with the solution..to use the ms - forms text box control and get data into the system clipboard..it goes something like this:

Private Sub CommandButtonCopy_Click()

Dim TxtCopy As String
Dim mydata As DataObject

TxtCopy = Sheet1.TextBoxDataDsply.Value
Set mydata = New DataObject

mydata.SetText TxtCopy
mydata.PutInClipboard
Set mydata = Nothing


End Sub

mdmackillop
01-17-2006, 02:55 PM
Hi asingh,
I'm happy to see your problem solved. How about creating a KB item based on the alternative solutions for other's benefit. Feel free to use my contribution in any item.
Regards
MD