Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Ribbons depending on ActiveSheet

I'm new to ribbons, but currently working on a project which requires a
custom ribbon, and all the default/normal/standard ribbons to be hidden.
This is no problem - I got this :-)

But, when some of the worksheets in the workbook becomes active, all the
normal ribbons should then become useful/visible again - until yet again,
the worksheets, which should only have the custom one, becomes active...

How to decide which ribbons should be visible, depending on wich worksheet
is the active sheet?


Thanks,

CE



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com


---
Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret.
http://www.avast.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Ribbons depending on ActiveSheet

I'm new to ribbons, but currently working on a project which requires
a custom ribbon, and all the default/normal/standard ribbons to be
hidden.
This is no problem - I got this :-)


Then you already know this is handled via the xml in your project file
when it opens. AFAIK, the Ribbon is not exposed to VBA!

But, when some of the worksheets in the workbook becomes active, all
the normal ribbons should then become useful/visible again - until
yet again, the worksheets, which should only have the custom one,
becomes active...

How to decide which ribbons should be visible, depending on wich
worksheet is the active sheet?


What you want here is the 'effect' of making your project
context-sensitive. I've beat myself up pretty badly trying to make that
happen with the ribbon, without success. My solution was to make only
the Addins tab visible, put my project's name as its 'label', and use
the same menus/toolbar as I use in the early versions. (That includes
customizing the Home/File menus as well)

---
This email is free from viruses and malware because avast! Antivirus
protection is active.
http://www.avast.com

You can suppress these advertisements in Avast 'Mail Shield Settings'
on the 'Behavior' page.<g

---
Denne e-mail er fri for virus og malware fordi avast! Antivirus
beskyttelse er aktiveret.
http://www.avast.com


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Ribbons depending on ActiveSheet

Hi Charlotte,

Am Tue, 20 May 2014 21:04:02 +0200 schrieb Charlotte E.:

I'm new to ribbons, but currently working on a project which requires a
custom ribbon


please have a look:
http://www.rondebruin.nl/win/section2.htm


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Ribbons depending on ActiveSheet

Hi Charlotte,

Am Tue, 20 May 2014 21:04:02 +0200 schrieb Charlotte E.:

I'm new to ribbons, but currently working on a project which
requires a custom ribbon


please have a look:
http://www.rondebruin.nl/win/section2.htm


Regards
Claus B.


Learned something new! Thanks...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Ribbons depending on ActiveSheet

You can suppress these advertisements in Avast 'Mail Shield Settings' on
the 'Behavior' page.<g


THANKS!

Been annoyed y these for a long time, but didn't know, it was possible to
turn them off...

CE



---
Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret.
http://www.avast.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Ribbons depending on ActiveSheet

Denne e-mail er fri for virus og malware fordi avast! Antivirus
beskyttelse er aktiveret.
http://www.avast.com



Hmmm...

Didn't work???

CE



---
Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret.
http://www.avast.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Ribbons depending on ActiveSheet

Denne e-mail er fri for virus og malware fordi avast! Antivirus
beskyttelse er aktiveret.
http://www.avast.com



Hmmm...

Didn't work???

CE



---
Denne e-mail er fri for virus og malware fordi avast! Antivirus
beskyttelse er aktiveret.
http://www.avast.com


I see only 1 now. Not sure where else you have this enabled but your
home language settings might be where to look.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Ribbons depending on ActiveSheet

Claus' link had some interesting stuff I hadn't seen yet from RdB.
Looks like you're in luck with your intent!<g

I looked at Ron's enable/disable samples some time ago looking to
replace my context-sensitive scheme for toolbars going with custom tabs
in a dictator app config. I abondoned that approach because it uses the
'Tag' property of controls/groups. I'm already using Tag/Parameter
props and didn't want to disturb my methodology. I'm going to revisit
this with a new approach: some of my Tag/Parameter values are delimited
value sets/pairs. I believe I can make this work for all where
enable/disable will be able to occur using only the first element in
the Tag string with a wildcard "*" as exampled in Ron's demo. This, of
course, means a rewrite of code but seems worth it in the long run...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Ribbons depending on ActiveSheet


"GS" wrote in message
Claus' link had some interesting stuff I hadn't seen yet from RdB. Looks
like you're in luck with your intent!<g

I looked at Ron's enable/disable samples some time ago looking to replace
my context-sensitive scheme for toolbars going with custom tabs in a
dictator app config. I abondoned that approach because it uses the 'Tag'
property of controls/groups. I'm already using Tag/Parameter props and
didn't want to disturb my methodology. I'm going to revisit this with a
new approach: some of my Tag/Parameter values are delimited value
sets/pairs. I believe I can make this work for all where enable/disable
will be able to occur using only the first element in the Tag string with
a wildcard "*" as exampled in Ron's demo. This, of course, means a rewrite
of code but seems worth it in the long run...


Garry,
Not sure which of Ron's examples you're looking at but typically you'd use
the tag (or id) property in the same callback that's called by multiple
controls. So when the same callback is called successively you can look at
the property to see if you want to change the return value. I assume the "*"
is being used with Like to do the same action to each control, though could
achieve the same objective in different ways.

Charlotte,
You didn't say which method you're using to hide the Ribbon (with things
like this it's better to be explain because it leads to different answers)
but there are basically two approaches.

1. Use StartFromScratch, and rebuild the Ribbon identically using your own
custom tabs & controls, or rather the built-in mso, together with callbacks
for the tabs to show/hide if/when required. This is typically used in
Dictator style apps where you want to hide everything including the QAT and
Office/Backstage menus. From memory Ron has excellent examples using
StartFromScratch so no need to add any more detail here.

2. For the builtin controls you want to show/hide include the "getVisible"
action in the xml, which for each can be to the same callback.
Also in the xml include the Ribbon's "onLoad" so you can set a reference to
it and do "Invalidate". Not sure if Ron includes examples not using
StartFromScratch, so a simplified xml might look like this

<customUI
xmlns = "http://schemas.microsoft.com/office/2006/01/customui"
onLoad="rxRibbon_onLoad"
<ribbon startFromScratch="false"
<tabs
<tab
idMso = "TabHome"
Tag = "TabHome"
getVisible="Tab_getVisible"/
<tab
idMso = "TabInsert"
Tag = "TabInsert"
getVisible="Tab_getVisible"/
</tabs
</ribbon
</customUI

the vba

Public grxRibbon As IRibbonUI
Public gbHide As Boolean

Sub rxRibbon_onLoad(ribbon As IRibbonUI)
Set grxRibbon = ribbon
' note while developing it's easy to lose the grxRibbon ref, but there's a
well known fix to restore it
End Sub

Sub Tab_getVisible(control As IRibbonControl, ByRef returnedVal)
' Debug.Print control.ID ' this might be useful
returnedVal = Not gbHide
End Sub

Sub test()
gbHide = Not gbHide
grxRibbon.Invalidate ' clears the cache and triggers the getVisible
callback
End Sub

Save/close an xlsm with the code, and add the above xml with the "Custom UI
Editor". Open the xlsm and manually run Sub test() to goggle visibility of
the Home & Insert tabs. Add similar xml for the other builtin tabs, these
are the main ones
TabHome
TabInsert
TabPageLayoutExcel
TabFormulas
TabData
TabReview
TabView
TabDeveloper
TabAddIns

could also include the contextural tabs

There are advantages & disadvantages to using StartFromScratch, or depending
on how much you want to hide (eg Office/BackStage QAT, custom ribbon stuff
from other addins) StartFromScratch might be the only way.

Regards,
Peter T




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Ribbons depending on ActiveSheet


Not sure what when wrong with the xml as posted, try this

<customUI
xmlns = "http://schemas.microsoft.com/office/2006/01/customui"
onLoad="rxRibbon_onLoad"
<ribbon startFromScratch="false"
<tabs
<tab
idMso = "TabHome"
Tag = "TabHome"
getVisible="Tab_getVisible"/
<tab
idMso = "TabInsert"
Tag = "TabInsert"
getVisible="Tab_getVisible"/
</tabs
</ribbon
</customUI

PT





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Ribbons depending on ActiveSheet

Garry,
Not sure which of Ron's examples you're looking at but typically
you'd use the tag (or id) property in the same callback that's called
by multiple controls. So when the same callback is called
successively you can look at the property to see if you want to
change the return value. I assume the "*" is being used with Like to
do the same action to each control, though could achieve the same
objective in different ways.


Yep, got that (thanks) from Ron's examples. Would be nice, though, to
know what other properties are available (if any). I'm looking to use
the ID for stuff like hide/show, enable/disable so I can continue using
Tag in the fashion I'm accustomed. I'll keep looking through Ron's
stuff, though!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Ribbons depending on ActiveSheet


"GS" wrote in message

Would be nice, though, to know what other properties are available (if
any). I'm looking to use the ID for stuff like hide/show, enable/disable
so I can continue using Tag in the fashion I'm accustomed.


control As IRibbonControl

Only .ID and .Tag. Sometimes you can use either for the same purpose (to
identify the control) though with the built-in controls you can only assign
a Tag (because its id is an idMSO).

An object control.Context is also returned which seems to be the
application's main window.

Regards,
Peter T


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Ribbons depending on ActiveSheet

"GS" wrote in message

Would be nice, though, to know what other properties are available
(if any). I'm looking to use the ID for stuff like hide/show,
enable/disable so I can continue using Tag in the fashion I'm
accustomed.


control As IRibbonControl

Only .ID and .Tag. Sometimes you can use either for the same purpose
(to identify the control) though with the built-in controls you can
only assign a Tag (because its id is an idMSO).

An object control.Context is also returned which seems to be the
application's main window.

Thanks!
I see Context in the intellisense dropdown and was hoping for
confirmation that it's also useable in the same fashion. Purpose is to
'flag' for enable/disable and/or hide/show in context with 'AppMode'.
I'm assuming that whatever Ctrl.Context returns got assigned somehow!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Ribbons BigRik Excel Discussion (Misc queries) 2 September 26th 08 04:11 AM
Ribbons sunshine New Users to Excel 4 September 4th 08 08:42 PM
Use a password in VBA ActiveSheet.protect & ActiveSheet.unprotect? Jim K. Excel Programming 2 June 2nd 08 08:09 PM
Ribbons / VBA example MrT Excel Programming 7 November 20th 06 10:51 PM
Copying new activesheet after other activesheet is hidden? Simon Lloyd[_790_] Excel Programming 1 June 20th 06 10:02 AM


All times are GMT +1. The time now is 03:33 PM.

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

About Us

"It's about Microsoft Excel"