ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to catch copy/paste & cut/paste ? (https://www.excelbanter.com/excel-programming/292621-how-catch-copy-paste-cut-paste.html)

Arifi Koseoglu

How to catch copy/paste & cut/paste ?
 
Hello everyone,

Quite new to VBA etc stuff (but not new to programming), I am looking on
ways to catch a user's copy/cut + paste command from all possible locations
(edit menu, keyboard shortcuts, other if any (are there others?), then do
some modifications in the cells being copied/moved and then paste to
wherever the user wanted to copy the stuff.

How do I do that ?

Many thanks in advance,
-arifi



serkan

How to catch copy/paste & cut/paste ?
 
This one prevents people from all ways of cutting/copying
and pasting when your workbook is open. I think you can
derive what you need from that...

Run DisableCutAndPaste from a suitable event procedure
(e.g. Workbook_Open or Worksheet_Activate) and
EnableCutAndPaste
from another (e.g. Workbook_Close or
Worksheet_Deactivate).

Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "+{DEL}", ""
Application.OnKey "+{INSERT}", ""
Application.CellDragAndDrop = False
End Sub

Sub EnableCutAndPaste()
EnableControl 21, True ' cut
EnableControl 19, True ' copy
EnableControl 22, True ' paste
EnableControl 755, True ' pastespecial
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "+{DEL}"
Application.OnKey "+{INSERT}"
Application.CellDragAndDrop = True
End Sub

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub




-----Original Message-----
Hello everyone,

Quite new to VBA etc stuff (but not new to programming),

I am looking on
ways to catch a user's copy/cut + paste command from all

possible locations
(edit menu, keyboard shortcuts, other if any (are there

others?), then do
some modifications in the cells being copied/moved and

then paste to
wherever the user wanted to copy the stuff.

How do I do that ?

Many thanks in advance,
-arifi


.


Arifi Koseoglu

How to catch copy/paste & cut/paste ?
 
Yes, this will do the job probably.

Many thanks.

Cheers
-arifi


"Serkan" wrote in message
...
This one prevents people from all ways of cutting/copying
and pasting when your workbook is open. I think you can
derive what you need from that...

Run DisableCutAndPaste from a suitable event procedure
(e.g. Workbook_Open or Worksheet_Activate) and
EnableCutAndPaste
from another (e.g. Workbook_Close or
Worksheet_Deactivate).

Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "+{DEL}", ""
Application.OnKey "+{INSERT}", ""
Application.CellDragAndDrop = False
End Sub

Sub EnableCutAndPaste()
EnableControl 21, True ' cut
EnableControl 19, True ' copy
EnableControl 22, True ' paste
EnableControl 755, True ' pastespecial
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "+{DEL}"
Application.OnKey "+{INSERT}"
Application.CellDragAndDrop = True
End Sub

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub




-----Original Message-----
Hello everyone,

Quite new to VBA etc stuff (but not new to programming),

I am looking on
ways to catch a user's copy/cut + paste command from all

possible locations
(edit menu, keyboard shortcuts, other if any (are there

others?), then do
some modifications in the cells being copied/moved and

then paste to
wherever the user wanted to copy the stuff.

How do I do that ?

Many thanks in advance,
-arifi


.




Arifi Koseoglu

How to catch copy/paste & cut/paste (New Dimension) ?
 
Hi...

Again, thanks for the information below.

Now the question has taken a different form though.

As I understand, the mechanisms I implement similar to the ones below exist
in the workbook they are defined in only (as expected). But, what I need to
have is that the mechanism I implement will be available vor every excel
worksheet opened in the company. Is there a mechanism to create a "master"
or whatever excel file to be installed on everyones PC that will incorporate
my stuff into their excel sessions ?

TIA,A
-arifi


"Serkan" wrote in message
...
This one prevents people from all ways of cutting/copying
and pasting when your workbook is open. I think you can
derive what you need from that...

Run DisableCutAndPaste from a suitable event procedure
(e.g. Workbook_Open or Worksheet_Activate) and
EnableCutAndPaste
from another (e.g. Workbook_Close or
Worksheet_Deactivate).

Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "+{DEL}", ""
Application.OnKey "+{INSERT}", ""
Application.CellDragAndDrop = False
End Sub

Sub EnableCutAndPaste()
EnableControl 21, True ' cut
EnableControl 19, True ' copy
EnableControl 22, True ' paste
EnableControl 755, True ' pastespecial
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "+{DEL}"
Application.OnKey "+{INSERT}"
Application.CellDragAndDrop = True
End Sub

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub




-----Original Message-----
Hello everyone,

Quite new to VBA etc stuff (but not new to programming),

I am looking on
ways to catch a user's copy/cut + paste command from all

possible locations
(edit menu, keyboard shortcuts, other if any (are there

others?), then do
some modifications in the cells being copied/moved and

then paste to
wherever the user wanted to copy the stuff.

How do I do that ?

Many thanks in advance,
-arifi


.




No Name

How to catch copy/paste & cut/paste (New Dimension) ?
 
I think you'll have to put that file under XLStart folder
(Excel automatically loads the files there at start-up) on
every machine.

-----Original Message-----
Hi...

Again, thanks for the information below.

Now the question has taken a different form though.

As I understand, the mechanisms I implement similar to

the ones below exist
in the workbook they are defined in only (as expected).

But, what I need to
have is that the mechanism I implement will be available

vor every excel
worksheet opened in the company. Is there a mechanism to

create a "master"
or whatever excel file to be installed on everyones PC

that will incorporate
my stuff into their excel sessions ?

TIA,A
-arifi


"Serkan" wrote in

message
...
This one prevents people from all ways of

cutting/copying
and pasting when your workbook is open. I think you can
derive what you need from that...

Run DisableCutAndPaste from a suitable event procedure
(e.g. Workbook_Open or Worksheet_Activate) and
EnableCutAndPaste
from another (e.g. Workbook_Close or
Worksheet_Deactivate).

Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "+{DEL}", ""
Application.OnKey "+{INSERT}", ""
Application.CellDragAndDrop = False
End Sub

Sub EnableCutAndPaste()
EnableControl 21, True ' cut
EnableControl 19, True ' copy
EnableControl 22, True ' paste
EnableControl 755, True ' pastespecial
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "+{DEL}"
Application.OnKey "+{INSERT}"
Application.CellDragAndDrop = True
End Sub

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub




-----Original Message-----
Hello everyone,

Quite new to VBA etc stuff (but not new to

programming),
I am looking on
ways to catch a user's copy/cut + paste command from

all
possible locations
(edit menu, keyboard shortcuts, other if any (are there

others?), then do
some modifications in the cells being copied/moved and

then paste to
wherever the user wanted to copy the stuff.

How do I do that ?

Many thanks in advance,
-arifi


.



.



All times are GMT +1. The time now is 12:31 AM.

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