Protection with macro & paste

P

PJP

Hi

I'm using a macro for protecting work sheets while enabling th
grouping:
Private Sub Worksheet_Activate()
With Me
.EnableOutlining = True
.Protect "password", UserInterfaceOnly:=True
End With
End Sub

But it is not possible to copy-paste data from other sheet to unlocke
cells. With normal protection it seems to be OK.

Any hints what's happening & how to go around?


Thanks
PJ
 
J

Jim Rech

But it is not possible to copy-paste data from other sheet to unlocked
cells.

I can't duplicate this problem. I had no problem manually copying to
unlocked cells in a worksheet protected with userinterfaceonly set.
 
D

Dave Peterson

First, I think you want dots in front of your .enableoutlining and .protect:

Private Sub Worksheet_Activate()
With Me
.EnableOutlining = True
.Protect "password", UserInterfaceOnly:=True
End With
End Sub

(It didn't matter in my simple testing, but if you have the "With/End With", you
might as well use them.)

But I could duplicate your problem in xl2002.

I think it's because most (all?) non-trivial macros turn off the cutcopymode.
(Clears the clipboard.)

And each time you activated the worksheet, you're code runs, the clipboard is
cleared and the paste option is disabled.

Instead of setting this when you activate the worksheet--just set it once--when
you open the workbook. Unless you're doing something pretty special, you only
have to set it once and forget it. (Something special would include removing
the protection completely and only reapplying in the _activate event.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top