Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is there any protection change event?

I am working with Excel 2007 and VSTO.

I have added several buttons to the ribbon which format cells. I want to
disable these buttons on protected worksheets, in the same way that the MS
"Wrap Text" button behaves.

I have a "getEnabled" callback which works fine but I don't know how to
invalidate my buttons when the protection is changed.

Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Is there any protection change event?

There is no protection change event but it is easy to trap the user changing
sheet protection through the ribbon UI.

First enhance your RibbonX to repurpose the SheetProtect control:

<?xml version="1.0" encoding="utf-8" ?
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
<commands
<command idMso="SheetProtect" onAction="mySheetProt"/
</commands
...other stuff


Then add the mySheetProt callback to your VB code:

Sub mySheetProt(control As IRibbonControl, ByRef cancelDefault)
Application.OnTime DateAdd("s", 1, Now), "InvalidateRibbon"
cancelDefault = False ''Allow normal Sheet Protection dialog
End Sub

Sub InvalidateRibbon()
Beep ''Test - Add ribbon invalidate code here
End Sub

--
Jim
"Alice Graham" wrote in message
...
|I am working with Excel 2007 and VSTO.
|
| I have added several buttons to the ribbon which format cells. I want to
| disable these buttons on protected worksheets, in the same way that the MS
| "Wrap Text" button behaves.
|
| I have a "getEnabled" callback which works fine but I don't know how to
| invalidate my buttons when the protection is changed.
|
| Any help would be appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is there any protection change event?

Jim,

That sounds like it would be a good solution. However, I am working with a
C# addin so I don't know how to pass a method to OnTime rather than a
procedure.

I don't suppose you know how to do that, do you?!

Anyway,
Thanks for your help.

"Jim Rech" wrote:

There is no protection change event but it is easy to trap the user changing
sheet protection through the ribbon UI.

First enhance your RibbonX to repurpose the SheetProtect control:

<?xml version="1.0" encoding="utf-8" ?
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
<commands
<command idMso="SheetProtect" onAction="mySheetProt"/
</commands
...other stuff


Then add the mySheetProt callback to your VB code:

Sub mySheetProt(control As IRibbonControl, ByRef cancelDefault)
Application.OnTime DateAdd("s", 1, Now), "InvalidateRibbon"
cancelDefault = False ''Allow normal Sheet Protection dialog
End Sub

Sub InvalidateRibbon()
Beep ''Test - Add ribbon invalidate code here
End Sub

--
Jim
"Alice Graham" wrote in message
...
|I am working with Excel 2007 and VSTO.
|
| I have added several buttons to the ribbon which format cells. I want to
| disable these buttons on protected worksheets, in the same way that the MS
| "Wrap Text" button behaves.
|
| I have a "getEnabled" callback which works fine but I don't know how to
| invalidate my buttons when the protection is changed.
|
| Any help would be appreciated.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is there any protection change event?

Also,

the sheetProtect brings up a dialogue for the user to choose what exact
protection they want. Wouldn't this method invalidate the ribbon before the
user had made their decision?

"Jim Rech" wrote:

There is no protection change event but it is easy to trap the user changing
sheet protection through the ribbon UI.

First enhance your RibbonX to repurpose the SheetProtect control:

<?xml version="1.0" encoding="utf-8" ?
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
<commands
<command idMso="SheetProtect" onAction="mySheetProt"/
</commands
...other stuff


Then add the mySheetProt callback to your VB code:

Sub mySheetProt(control As IRibbonControl, ByRef cancelDefault)
Application.OnTime DateAdd("s", 1, Now), "InvalidateRibbon"
cancelDefault = False ''Allow normal Sheet Protection dialog
End Sub

Sub InvalidateRibbon()
Beep ''Test - Add ribbon invalidate code here
End Sub

--
Jim
"Alice Graham" wrote in message
...
|I am working with Excel 2007 and VSTO.
|
| I have added several buttons to the ribbon which format cells. I want to
| disable these buttons on protected worksheets, in the same way that the MS
| "Wrap Text" button behaves.
|
| I have a "getEnabled" callback which works fine but I don't know how to
| invalidate my buttons when the protection is changed.
|
| Any help would be appreciated.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is there any protection change event?

Jim,

Thanks, got there in the end.

I repurpose the command then simply invalidate the buttons.
There is no need to use onTime method as it seems the ribbon waits until the
default action is carried out before any getEnabled callbacks are made.

Thanks,
Alice

"Jim Rech" wrote:

There is no protection change event but it is easy to trap the user changing
sheet protection through the ribbon UI.

First enhance your RibbonX to repurpose the SheetProtect control:

<?xml version="1.0" encoding="utf-8" ?
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
<commands
<command idMso="SheetProtect" onAction="mySheetProt"/
</commands
...other stuff


Then add the mySheetProt callback to your VB code:

Sub mySheetProt(control As IRibbonControl, ByRef cancelDefault)
Application.OnTime DateAdd("s", 1, Now), "InvalidateRibbon"
cancelDefault = False ''Allow normal Sheet Protection dialog
End Sub

Sub InvalidateRibbon()
Beep ''Test - Add ribbon invalidate code here
End Sub

--
Jim



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Is there any protection change event?

Sorry, forgot to check back.<g But I'm glad you got it to work.

--
Jim
"Alice Graham" wrote in message
...
| Jim,
|
| Thanks, got there in the end.
|
| I repurpose the command then simply invalidate the buttons.
| There is no need to use onTime method as it seems the ribbon waits until
the
| default action is carried out before any getEnabled callbacks are made.
|
| Thanks,
| Alice
|
| "Jim Rech" wrote:
|
| There is no protection change event but it is easy to trap the user
changing
| sheet protection through the ribbon UI.
|
| First enhance your RibbonX to repurpose the SheetProtect control:
|
| <?xml version="1.0" encoding="utf-8" ?
| <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
| <commands
| <command idMso="SheetProtect" onAction="mySheetProt"/
| </commands
| ...other stuff
|
|
| Then add the mySheetProt callback to your VB code:
|
| Sub mySheetProt(control As IRibbonControl, ByRef cancelDefault)
| Application.OnTime DateAdd("s", 1, Now), "InvalidateRibbon"
| cancelDefault = False ''Allow normal Sheet Protection dialog
| End Sub
|
| Sub InvalidateRibbon()
| Beep ''Test - Add ribbon invalidate code here
| End Sub
|
| --
| Jim


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is there any protection change event?

Unfortunately, I was too quick to decide I had it working.

Yes, what I've got works fine if the user clicks on the protection button,
or uses the new keytips. However, it does not work when the user changes
protection by running a macro, or by using the old 2003 key combinations.

Any suggestions for how to handle that or am I being too optimistic about
what I can achieve?

"Jim Rech" wrote:

Sorry, forgot to check back.<g But I'm glad you got it to work.

--
Jim
"Alice Graham" wrote in message
...
| Jim,
|
| Thanks, got there in the end.
|
| I repurpose the command then simply invalidate the buttons.
| There is no need to use onTime method as it seems the ribbon waits until
the
| default action is carried out before any getEnabled callbacks are made.
|
| Thanks,
| Alice
|
| "Jim Rech" wrote:
|
| There is no protection change event but it is easy to trap the user
changing
| sheet protection through the ribbon UI.
|
| First enhance your RibbonX to repurpose the SheetProtect control:
|
| <?xml version="1.0" encoding="utf-8" ?
| <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
| <commands
| <command idMso="SheetProtect" onAction="mySheetProt"/
| </commands
| ...other stuff
|
|
| Then add the mySheetProt callback to your VB code:
|
| Sub mySheetProt(control As IRibbonControl, ByRef cancelDefault)
| Application.OnTime DateAdd("s", 1, Now), "InvalidateRibbon"
| cancelDefault = False ''Allow normal Sheet Protection dialog
| End Sub
|
| Sub InvalidateRibbon()
| Beep ''Test - Add ribbon invalidate code here
| End Sub
|
| --
| Jim



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet_Change Event with Range Protection Judy P. Excel Discussion (Misc queries) 3 October 28th 10 08:07 PM
MsgBox in Enter event causes combobox not to run Change event Richard Excel Programming 0 March 6th 06 02:52 PM
Change event and calculate event Antje Excel Programming 1 March 29th 05 09:03 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM


All times are GMT +1. The time now is 09:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"