Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Deactivate / Reactivate the Paste Function in excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
missk - 15 Jan 2008 22:37 GMT
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
Nigel - 16 Jan 2008 08:02 GMT
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

Signature

Regards,
Nigel
nigelnospam@9sw.co.uk

> Hi,
>
[quoted text clipped - 28 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.