View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
DM Unseen DM Unseen is offline
external usenet poster
 
Posts: 233
Default Cutcopymode problem

Roman,

The following can be observed about Excel:

- When selecting a range and copying it to the clipboard excel will try
to remember the range. When you then paste again INTO excel, excel will
use that range agian. You can see this by doing a cut, this willl not
clear the range in excel until you did a paste, and if the paste is in
another app, it will never clear the range! Remembering the copied
range is essential, but Excel can only remember it as long as you do
not do any destructive action.
A destructive action is: allmost all GUI actions including editing of
cells, but not selecting cells. Also through VBA touching format
functions or clearing cells.

As soon as you do this excel will lose its copied range(the dashed line
vanishes) and it will clear the clipboard!

Note that this strange behavior can be traced back to Excel's XLM
roots. A lot of VBA functions are (in a sense) using XLM macro's which
where the programming tool of Excel 5 and earlier. Some of those macro
comands (ie action commands) E.g. the XLM FORMAT(CELL) macro command
or the "SELECT" macro comman show this behavior. I suspect these
"commands" are actually the real culprits. So I suspect all VBA
comands using XLM give you this behaviour. Intersetingly enough VBA
Select(ion) was wisely enough implemented another way, so most of those
actions will not clear the clipboad. This goes for other VBA commands
as well, but some commands still show the strange behaviors of the XLM
forefathers.

Why XLM is implemenetd this way I would not know since I do not have
much exp with that. I suspect XLM could not distinguish between a
selection and a clipboard selection(i.e. just one type of selection
available).

DM Unseen

PS some code I used for testing (to show I'm not just blabbering;)

Range("A1:D9").ClearContents
Application.ExecuteExcel4Macro("SELECT(""$A$9"","" !$A$9"")")
Application.ExecuteExcel4Macro("FORMAT.NUMBER(""@" ")")
Application.ExecuteExcel4Macro "SELECT(""!$C$3:$E$5"", ""!$C$5"")"
Application.ExecuteExcel4Macro "SELECT(, ""R[10]C[5]"")"