Clipboard contents lost (Excel2000/Win XP)

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Clipboard contents lost (Excel2000/Win XP)

Post by ChrisGreaves »

I struck what to me is an oddity today.
I have open both Excel 2000 and Word 2000.
In Word2000 I have a little macro 'PasteExCell' which pastes the contents of the clipboard into the activedocument then converts the 1-cell table into text, removes the paragraph marks and so on (Yes, I could probably use a better paste method, but you know ...).
In Excel I choose Edit, Copy, then Alt-Tab to Word, run the macro.
Works fine.
Then one time after Edit Copy I decided to delete the cell contents, having no further use for them, and believing them to be safely ensconced in the clipboard.
Not so.
It appears that Excel2000 decides that if the contents have been deleted then so ought the clipboard copy.
At first this seemed to make sense, after all, if you wanted to use a dynamic link .. but then I thought No! The great thing about dynamic links is that you change the source (originally identified through the Copy/pasteLink operation) and the target is updated automatically.
Deleting the original cell contents should deliver a null value to the target, NO?
He who plants a seed, plants life.

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Clipboard contents lost (Excel2000/Win XP)

Post by HansV »

Excel behaves differently than most other applications - it clears the clipboard at the drop of a hat.

You can easily verify this:
  • Select a cell.
  • Copy it to the clipboard (press Ctrl+C or select Edit | Copy or click Copy on the Standard toolbar).
  • You will see a blinking border around the cell, and Excel's status bar will display "Select destination and press ENTER or choose Paste".
  • If you select another cell, the copied cell will keep the blinking border - the cell is still on the clipboard, ready to be pasted. The same happens if you change the width of a column or the height of a row.
  • But if you perform almost any other action - edit the value of a cell, format a cell, ... - the blinking border and the status bar message will disappear. This indicates that the clipboard has been cleared. If you try to paste, either in Excel or in another application such as Word, nothing will happen.
So in general, you have to paste immediately after copying.

It's different if you copy a cell's value/formula:
  • Select a cell.
  • Click in the formula bar.
  • Select the entire value/formula.
  • Press Ctrl+C to copy the selected text to the clipboard.
  • Press Esc or click the red X to the left of the formula to exit the formula bar.
  • Edit the cell, and perform some other actions (except copying/pasting).
  • If you paste, either in Excel or in another application such as Word, the value/formula that you copied will be pasted, even if you edited the cell after copying. Note that the formatting of the original cell is not pasted, only the text from the formula bar.
If you copy a cell, Excel places the cell on the clipboard as a Range object, and it is prone to clear this object if you perform another action in Excel.
If you copy from the formula bar, Excel places the text on the clipboard as a Text string, and this is preserved until something else is placed on the clipboard.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Clipboard contents lost (Excel2000/Win XP)

Post by ChrisGreaves »

HansV wrote:If you copy a cell, Excel places the cell on the clipboard as a Range object, and it is prone to clear this object if you perform another action in Excel.
If you copy from the formula bar, Excel places the text on the clipboard as a Text string, and this is preserved until something else is placed on the clipboard.
Thanks Hans for the clarification.
I've used both techniques (cell vs. bar) for years without realising that Excel kept one on a string and would yank it back at the drop of a keystroke.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Clipboard contents lost (Excel2000/Win XP)

Post by ChrisGreaves »

HansV wrote:Excel behaves differently than most other applications...
FWIW I'm aware of other differences in Windows, although it may be Windows' reaction to my timing.
I'm re-arranging my MP3 folders, moving sub-folders with no vocals to "Instrumentals", and the remainder to "Vocals", using the time-honored technique of right-click, Cut, right-click, Paste.
Or sometimes right-click, Cut, up-arrow, Ctrl-V
I have a vague sense that the first method - using the mouse to paste - causes the by-now large "Instrumentals" folder to expand (and obliterate any useful data in my view), whereas using the keyboard Ctrl-V to paste leaves the "Instrumental" folder collapsed.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Clipboard contents lost (Excel2000/Win XP)

Post by ChrisGreaves »

HansV wrote:It's different if you copy a cell's value/formula:
[*]If you paste, either in Excel or in another application such as Word, the value/formula that you copied will be pasted, even if you edited the cell after copying. Note that the formatting of the original cell is not pasted, only the text from the formula bar.
Strangely this came in handy this morning.
I had an Excel cell text label in sentence case; I copy/pasted it to Word, Title-cased it, and copy/pasted it back to Excel, clobbering the Excel formatting.
Trying again, this time editing the text label and pasting into the formula bar was much more aesthetic!
He who plants a seed, plants life.