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 / Worksheet Functions / May 2008

Tip: Looking for answers? Try searching our database.

Disable Pasting into a Workbook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
scottyboy - 23 Apr 2008 14:10 GMT
Hi
I have a workbook, Wb1.  I would like to be able to copy from Wb1 and paste
to any other Wb but disable pasting into Wb1.
Signature

Cheers

Scotty

ryguy7272 - 23 Apr 2008 14:59 GMT
http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm

Regards,
Ryan--
Signature

RyGuy

> Hi
> I have a workbook, Wb1.  I would like to be able to copy from Wb1 and paste
> to any other Wb but disable pasting into Wb1.
scottyboy - 09 May 2008 12:21 GMT
I have compiled the below code, when i copy from wb1 and go to copy into wb2
paste option is not available unless i open a new excel session.  Think it
may have something to do with the clipboard.  Any suggestions?

Public Switching As Boolean
Private Sub Workbook_activate()
   DisableCutAndPaste
   Switching = True
   End Sub
Private Sub Workbook_Deactivate()
   EnableCutAndPaste
   Switching = True
End Sub
Private Sub DisableCutAndPaste()
 EnableControl 21, False   ' cut
 EnableControl 19, True   ' 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

Private 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

Private 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
Private Sub Workbook_Open()
Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
   Sheets(i).Visible = True
Next i
Sheets("Warning").Visible = xlVeryHidden
Application.ScreenUpdating = True
End Sub

Private Sub Workbook_beforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
Sheets("Warning").Visible = True
  If Sheets(i).Visible = True And Sheets(i).Name <> "Warning" Then
     Sheets(i).Visible = xlVeryHidden
  End If
Next i
Application.DisplayAlerts = False
EnableCutAndPaste
End Sub
Signature

Cheers

Scotty

> http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm
>
[quoted text clipped - 4 lines]
> > I have a workbook, Wb1.  I would like to be able to copy from Wb1 and paste
> > to any other Wb but disable pasting into Wb1.
 
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.