PC Review


Reply
Thread Tools Rate Thread

Deactivate / Reactivate the Paste Function in excel

 
 
missk
Guest
Posts: n/a
 
      15th Jan 2008
Hi,

I have a macro that deactivates the paste function in excel.
The re-activation of the paste function occurs before the file is
close (beforeclose), see below.
I have applied this to multiple workbooks, but I noticed that when I
have multiple workbook open, if I close one workbook then the paste
function is effective switch back on. Is there a way around this?

Instead of beforeclose could I trigger the re-activation only when
excel is shut down completely?

Thank you

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Enable the menu:
Application.CommandBars("Edit").Controls(3).Enabled = True
Application.CommandBars("Edit").Controls(4).Enabled = True
Application.CommandBars("Edit").Controls(5).Enabled = True
Application.CommandBars("Edit").Controls(6).Enabled = True
' Enable the commandbar:
Application.CommandBars("Standard").Controls(7).Enabled = True
Application.CommandBars("Standard").Controls(8).Enabled = True
Application.CommandBars("Standard").Controls(9).Enabled = True
Application.CommandBars("Standard").Controls(10).Enabled = True
' Enable the shortcut keys:
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "^x"
Application.CommandBars("Cell").Enabled = True

End Sub
 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      16th Jan 2008
Not really, but you could include a check that count the number of workbooks
open before you run this code. If it is only one then you know it is the
last one?

e.g.

If Workbooks.Count = 1 then
'Run your code
End if


--

Regards,
Nigel
(E-Mail Removed)



"missk" <(E-Mail Removed)> wrote in message
news:6eb00ab8-889f-4c23-bce9-(E-Mail Removed)...
> Hi,
>
> I have a macro that deactivates the paste function in excel.
> The re-activation of the paste function occurs before the file is
> close (beforeclose), see below.
> I have applied this to multiple workbooks, but I noticed that when I
> have multiple workbook open, if I close one workbook then the paste
> function is effective switch back on. Is there a way around this?
>
> Instead of beforeclose could I trigger the re-activation only when
> excel is shut down completely?
>
> Thank you
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> ' Enable the menu:
> Application.CommandBars("Edit").Controls(3).Enabled = True
> Application.CommandBars("Edit").Controls(4).Enabled = True
> Application.CommandBars("Edit").Controls(5).Enabled = True
> Application.CommandBars("Edit").Controls(6).Enabled = True
> ' Enable the commandbar:
> Application.CommandBars("Standard").Controls(7).Enabled = True
> Application.CommandBars("Standard").Controls(8).Enabled = True
> Application.CommandBars("Standard").Controls(9).Enabled = True
> Application.CommandBars("Standard").Controls(10).Enabled = True
> ' Enable the shortcut keys:
> Application.OnKey "^c"
> Application.OnKey "^v"
> Application.OnKey "^x"
> Application.CommandBars("Cell").Enabled = True
>
> End Sub


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deactivate a macro when used and reactivate again Ber Microsoft Excel Misc 1 23rd Apr 2010 04:35 PM
Deactivate then Reactivate UpdateLinks =?Utf-8?B?VE9NQg==?= Microsoft Excel Programming 2 24th Feb 2006 10:20 PM
Cannot deactivate, and reactivate Windows XP SP1 =?Utf-8?B?RGltaXRyaXMgQ2hvbnR6b3BvdWxvcw==?= Windows XP General 3 9th Dec 2005 08:56 AM
Deactivate and reactivate David Microsoft Windows 2000 Terminal Server Clients 2 8th Oct 2003 09:56 PM
deactivate - reactivate license server Dick Wright Microsoft Windows 2000 Terminal Server Clients 0 19th Aug 2003 11:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 PM.