Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Copying cell text to clipboard (using Putinclipboard)

Hi Guys,

I have a worksheet in which the cells are protected (userinterfaceonly)
which prevents the user from editing a cells contents.
However, for some cells, I would like them to be able to copy the contents
to the clipboard in order for them to work with it elsewhere.
Ive achieved this with a commandbutton which the user clicks to copy the
cell contents.

Code for commandbutton
Private Sub CommandButton1_Click()
Dim c As New DataObject
c.SetText Range("A" & ActiveCell.Row).Text
c.PutInClipboard
End Sub

The problem occurs if the cell content is quite long. It seems that there is
a limit to how much can be copied. Given that its possible to copy vast
quantities to the clipboard manually, I cant work out why this is.
To test this I took a blank sheet and in column A, rows 2 to 20 I placed
strings ranging in length from 20 to 2090 characters. I then added a button
and used it to copy the strings to the clipboard. I then pasted the clipboard
contents in an adjacent cell and compared the string lengths.
Ive discovered that the maximum number of characters that and be copied to
the clipboard is 1024. If you try and use the above code to copy a string
which is =1025 characters, when you paste the result it's only the first
1024!

Does anyone know why this is or how to get around it?

Many thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copying cell text to clipboard (using Putinclipboard)

The reason it is, is that Microsoft designed it that way. One way around it
is to do a direct copy and paste, bypassing the clipboard. eg:

Private Sub CommandButton1_Click()
Selection.Copy Sheets(2).Range("A1")
End Sub




"Libby" wrote:

Hi Guys,

I have a worksheet in which the cells are protected (userinterfaceonly)
which prevents the user from editing a cells contents.
However, for some cells, I would like them to be able to copy the contents
to the clipboard in order for them to work with it elsewhere.
Ive achieved this with a commandbutton which the user clicks to copy the
cell contents.

Code for commandbutton
Private Sub CommandButton1_Click()
Dim c As New DataObject
c.SetText Range("A" & ActiveCell.Row).Text
c.PutInClipboard
End Sub

The problem occurs if the cell content is quite long. It seems that there is
a limit to how much can be copied. Given that its possible to copy vast
quantities to the clipboard manually, I cant work out why this is.
To test this I took a blank sheet and in column A, rows 2 to 20 I placed
strings ranging in length from 20 to 2090 characters. I then added a button
and used it to copy the strings to the clipboard. I then pasted the clipboard
contents in an adjacent cell and compared the string lengths.
Ive discovered that the maximum number of characters that and be copied to
the clipboard is 1024. If you try and use the above code to copy a string
which is =1025 characters, when you paste the result it's only the first
1024!

Does anyone know why this is or how to get around it?

Many thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copying cell text to clipboard (using Putinclipboard)

Use .value, not .text.

..Text is the limiting factor.

c.SetText Range("A" & ActiveCell.Row).Value


Libby wrote:

Hi Guys,

I have a worksheet in which the cells are protected (userinterfaceonly)
which prevents the user from editing a cells contents.
However, for some cells, I would like them to be able to copy the contents
to the clipboard in order for them to work with it elsewhere.
Ive achieved this with a commandbutton which the user clicks to copy the
cell contents.

Code for commandbutton
Private Sub CommandButton1_Click()
Dim c As New DataObject
c.SetText Range("A" & ActiveCell.Row).Text
c.PutInClipboard
End Sub

The problem occurs if the cell content is quite long. It seems that there is
a limit to how much can be copied. Given that its possible to copy vast
quantities to the clipboard manually, I cant work out why this is.
To test this I took a blank sheet and in column A, rows 2 to 20 I placed
strings ranging in length from 20 to 2090 characters. I then added a button
and used it to copy the strings to the clipboard. I then pasted the clipboard
contents in an adjacent cell and compared the string lengths.
Ive discovered that the maximum number of characters that and be copied to
the clipboard is 1024. If you try and use the above code to copy a string
which is =1025 characters, when you paste the result it's only the first
1024!

Does anyone know why this is or how to get around it?

Many thanks in advance


--

Dave Peterson
Reply
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
Transfer clipboard from Task pane clipboard(office?) content to Excel (windows?) clipboard? tskogstrom Excel Programming 2 March 6th 07 12:50 PM
How have text on clipboard reformatted as a cell would be put there? RandyDtg1 Excel Programming 3 June 14th 04 02:17 AM
Copying cell value to clipboard to paste into adobe pdf maker Jooer Excel Programming 0 November 20th 03 07:45 AM
putInClipboard errors on mac subra Excel Programming 0 November 12th 03 03:39 PM
Copying the text from a text box to the clipboard TonyJeffs Excel Programming 1 August 31st 03 07:48 PM


All times are GMT +1. The time now is 02:59 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"