View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Marie J-son[_7_] Marie J-son[_7_] is offline
external usenet poster
 
Posts: 14
Default Clipboard turn empty running worksheet.unprotect - workaround ?

When testing, it seems like a lot of other changes empty the clipboard
also - when I copy a cell and change number format or font.bold with code
like below, the paste icon grays out right on the line. Is this true? Can I
not change anything without clipboard get empty.

The mystery closes up when I have one worksheet I run a lot of code on
including Font and numberformat that doesn't gray out the paste button -
until i come to last line " Exit Sub". When the code stop, the paste button
gray out.

Testsubs - I tested it on a brand new workbook with same result - 1/ Copy 2/
Run code 3/ can't paste anymo

Sub test()
Application.ActiveCell.Font.Bold = True
'Application.ActiveCell.NumberFormat = "@"
End Sub

What is happening?

/Regards

-----------------------


"Marie J-son" skrev i meddelandet
...
Hi,

I have a worksheet I need to have protected, and when I run code to
restore cell format, I unprotect it temporary. However, this causes
clipboard to turn empty and since I run the code both at
worksheet_activate and worksheet_change events, the result is that you
can't copy-paste between sheets.

At line below, the clipboard turn empty ...
"Application.Worksheets(XshtName).UnProtect Password:=sPass"

1/ Is there a way to work around this and still use the code both at
worksheet_change and worksheet_activate?
2/ The reason why I have it on worksheet_activate is because I want to
restore cell formats when drag and drop occure from other sheets - - it
doesn't trig the worksheet_change event, I'm told. Right? Workaround?


/Kind regards