ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cutcopymode problem (https://www.excelbanter.com/excel-programming/332514-cutcopymode-problem.html)

Roman[_4_]

Cutcopymode problem
 
Thanks for any help on following:

What I'm trying to do is to paste something as a text to an area which
format is "@". As I don't know its size I paste it, then change the
format of selection (pasted area) to "@" and paste it again. This works
fine when data in clipboard is not from Excel, if it is this doesnt
work.

I noticed that cutcopymode is always 0 when the data in clipboard is
not from Excel. If it is the cutcopymode is 1 until there's this line
in the code:

selection.numberformat = "@"

after this cutcopymode is always changing to 0.

I don't have it.


Tom Ogilvy

Cutcopymode problem
 
That is because the Selection.Numberformat = "@" clears the clipboard for a
copied range.

--
Regards,
Tom Ogilvy


"Roman" wrote in message
oups.com...
Thanks for any help on following:

What I'm trying to do is to paste something as a text to an area which
format is "@". As I don't know its size I paste it, then change the
format of selection (pasted area) to "@" and paste it again. This works
fine when data in clipboard is not from Excel, if it is this doesnt
work.

I noticed that cutcopymode is always 0 when the data in clipboard is
not from Excel. If it is the cutcopymode is 1 until there's this line
in the code:

selection.numberformat = "@"

after this cutcopymode is always changing to 0.

I don't have it.




Roman[_4_]

Cutcopymode problem
 
Thanks for explanation.
Why doesn't this happen when I put data into clipboard in another
application?
Do you know the purpose of that? I find it quite strange.


Tom Ogilvy

Cutcopymode problem
 
I don't know if I can say why. Why questions might need to be answered by
the developers of excel.

--
Regards,
Tom Ogilvy

"Roman" wrote in message
oups.com...
Thanks for explanation.
Why doesn't this happen when I put data into clipboard in another
application?
Do you know the purpose of that? I find it quite strange.




Roman[_4_]

Cutcopymode problem
 
That's true, thanks for your time anyway.
I'm sorry for silly questions but probably there are some of them still
waiting on my VB learning path...


DM Unseen

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]"")"


Roman[_4_]

Cutcopymode problem
 
DM,
thanks for your experiences. They are valued to me.
(Never suspected you of blabbering!)
Good day!



All times are GMT +1. The time now is 03:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com