Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
developer
active.documents
automation
binary.file_format
clipboard.dde
com.add_ins
hosting.controls
internet_other
office.sdks
officedev
officedev.other
outlook.forms
outlook.vba
smarttags
vba
web.components
  
 
date: Wed, 17 Sep 2008 13:23:43 -0600,    group: microsoft.public.office.developer.com.add_ins        back       


change the ribbon menu   
Hi;

How do I change the ribbon menu in my 2008 AddIn?

thanks - dave

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
date: Wed, 17 Sep 2008 13:23:43 -0600   author:   David Thielen am

RE: change the ribbon menu   
Hello Dave, 

Could you please clarify what you mean about the ribbon menu? I have the 
following two assumptions now. If what you are referring to is different 
from my assumptions, please let me know.

1.The Office Menu appears after clicking the Office button at the left top 
corner in the Office application. If that is the case, we can create the 
ribbon.xml file as the follows to customize that menu. To create a new 
control, we use the id attribute while using idMso attribute to identify 
the built-in control. We can get the detailed walkthrough in this MSDN 
document, http://msdn.microsoft.com/en-us/library/aa434078.aspx 

<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" 
xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <officeMenu>
      <button id="button1" label="button1" />
      <control idMso ="FileSave" enabled ="false"/>
    </officeMenu>
  </ribbon>
</customUI>

2.The context menu when right clicking the ribbon. It has three default 
menu items: "Customize Quick Access Toolbar", "Show Quick Access Toolbar 
below the Ribbon", "Minimize the Ribbon". If that is the case, personally 
speaking, I do not think this can be achieved in managed Office Add-in 
since this context menu is not exposed in the Office Object Model. I follow 
this article http://blogs.msdn.com/guowu/archive/2004/09/06/225963.aspx to 
iterate through all controls and command bars in Word. But this context 
menu does not appear in them. If this is your requirement, I will consult 
the product team about it to see if anyone has some other trick approach 
for this. Look forward your reply.

Have a good day!

Best regards,
Ji Zhou (v-jzho@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Thu, 18 Sep 2008 07:22:50 GMT   author:   (Ji Zhou [MSFT])

Re: change the ribbon menu   
Hi;

Sorry, when my AddIn starts it calls 
	public string GetCustomUI(string ribbonId)
and I give it the ribbon for my AddIn to place as one of the main tabs
on the ribbon across the top of the app.

How can I change that menu? In other words, give it a new xml file for
my AddIn's menu?

thanks - dave


On Thu, 18 Sep 2008 07:22:50 GMT, v-jzho@online.microsoft.com ("Ji
Zhou [MSFT]") wrote:

>Hello Dave, 
>
>Could you please clarify what you mean about the ribbon menu? I have the 
>following two assumptions now. If what you are referring to is different 
>from my assumptions, please let me know.
>
>1.The Office Menu appears after clicking the Office button at the left top 
>corner in the Office application. If that is the case, we can create the 
>ribbon.xml file as the follows to customize that menu. To create a new 
>control, we use the id attribute while using idMso attribute to identify 
>the built-in control. We can get the detailed walkthrough in this MSDN 
>document, http://msdn.microsoft.com/en-us/library/aa434078.aspx 
>
><?xml version="1.0" encoding="UTF-8"?>
><customUI onLoad="Ribbon_Load" 
>xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>  <ribbon>
>    <officeMenu>
>      <button id="button1" label="button1" />
>      <control idMso ="FileSave" enabled ="false"/>
>    </officeMenu>
>  </ribbon>
></customUI>
>
>2.The context menu when right clicking the ribbon. It has three default 
>menu items: "Customize Quick Access Toolbar", "Show Quick Access Toolbar 
>below the Ribbon", "Minimize the Ribbon". If that is the case, personally 
>speaking, I do not think this can be achieved in managed Office Add-in 
>since this context menu is not exposed in the Office Object Model. I follow 
>this article http://blogs.msdn.com/guowu/archive/2004/09/06/225963.aspx to 
>iterate through all controls and command bars in Word. But this context 
>menu does not appear in them. If this is your requirement, I will consult 
>the product team about it to see if anyone has some other trick approach 
>for this. Look forward your reply.
>
>Have a good day!
>
>Best regards,
>Ji Zhou (v-jzho@online.microsoft.com, remove 'online.')
>Microsoft Online Community Support
>
>Delighting our customers is our #1 priority. We welcome your comments and 
>suggestions about how we can improve the support we provide to you. Please 
>feel free to let my manager know what you think of the level of service 
>provided. You can send feedback directly to my manager at: 
>msdnmg@microsoft.com.
>
>==================================================
>Get notification to my posts through email? Please refer to 
>http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
>
>Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
>where an initial response from the community or a Microsoft Support 
>Engineer within 1 business day is acceptable. Please note that each follow 
>up response may take approximately 2 business days as the support 
>professional working with you may need further investigation to reach the 
>most efficient resolution. The offering is not appropriate for situations 
>that require urgent, real-time or phone-based interactions or complex 
>project analysis and dump analysis issues. Issues of this nature are best 
>handled working with a dedicated Microsoft Support Engineer by contacting 
>Microsoft Customer Support Services (CSS) at 
>http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.


david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
date: Thu, 18 Sep 2008 10:36:07 -0600   author:   David Thielen am

Re: change the ribbon menu   
"David Thielen" <thielen@nospam.nospam> wrote in message 
news:on05d4pv4bhao6pif6tucqa2h84f4o7udc@4ax.com...
> Hi;
>
> Sorry, when my AddIn starts it calls
> public string GetCustomUI(string ribbonId)
> and I give it the ribbon for my AddIn to place as one of the main tabs
> on the ribbon across the top of the app.
>
> How can I change that menu? In other words, give it a new xml file for
> my AddIn's menu?
>
> thanks - dave

Hi Dave, it's a puzzling question.  The string you return contains the XML. 
To change the XML you change the XML within your program that you are 
returning with the GetCustomUI call.  It's up to you whether that is data 
within your program or a file that you read in.  Either way you are 
responsible for the XML content that you return in GetCustomUI.

-- 
Scott McPhillips [VC++ MVP]
date: Thu, 18 Sep 2008 13:28:15 -0400   author:   Scott McPhillips [MVP] org-dot-mvps-at-scottmcp

Re: change the ribbon menu   
Hello Dave, 

Thanks for clarifying about this, so based on my understanding, we are 
trying to change the ribbon UI dynamically by specifying another ribbon xml 
file, right?

Far from my researching, I did not find any way to unload and reload the 
ribbon customization xml file dynamically. If we want to unload and reload 
the ribbon, at least we have to unload and reload our Add-in. Supposed that 
we choose this way to go, I think another Add-in should be necessary to 
control our Add-in's loading and unloading. But that is too bad. Thus, 
based on your requirement, may I suggest we use the following workaround 
instead?

We can put both of the two tabs in the same customization xml file. We 
define the getVisible callback function for these tabs. Whenever we want to 
show/hide a tab, we call ribbon.Invalidate. So the getVisible callback will 
be called, and we get chance to set the table's visible there.

Here are codes work on my side,

customUI.xml,

<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load"  
xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
      <tab id="tab1" label="tab1" getVisible ="GetVisible" >
        <group id="group1" label="group1">
          <button id="button1" label="button1" />
        </group>
      </tab>
      <tab id="tab2" label="tab2" getVisible ="GetVisible">
        <group id="group2" label="group2">
          <button id="button2" label="button2" />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

and the shared add in codes,

public IRibbonUI ribbon;
private Word.Application applicationObject;
private object addInInstance;
private string visibleTab;

public string GetCustomUI(string RibbonID)
{
   using (StreamReader resourceReader = new 
StreamReader(@"D:\customUI.xml"))
   {
      if (resourceReader != null)
      {
         return resourceReader.ReadToEnd();
      }
   }
   return null;
}

public void Ribbon_Load(IRibbonUI ribbonUI)
{
   visibleTab = "tab1";
   this.ribbon = ribbonUI;
}

public bool GetVisible(IRibbonControl control)
{
   if (control.Id == visibleTab)
   {
      return true;
   }
   else
   {
     return false;
   }
}

public void OnConnection(object application, 
            Extensibility.ext_ConnectMode connectMode, 
            object addInInst, ref System.Array custom)
{
   applicationObject = application as Word.Application;
   addInInstance = addInInst;
   applicationObject.WindowSize += new 
Microsoft.Office.Interop.Word.ApplicationEvents4_WindowSizeEventHandler(appl
icationObject_WindowSize);
}

void applicationObject_WindowSize(Microsoft.Office.Interop.Word.Document 
Doc, Microsoft.Office.Interop.Word.Window Wn)
{
   if (visibleTab == "tab1")
   {
      visibleTab = "tab2";
   }
   else
   {
      visibleTab = "tab1";
   }
   this.ribbon.Invalidate();
}

I use the Application.WindowSize event as a trigger to switch between tab1 
and tab2 in the above codes. Please let me know if this suggestion works 
for your scenario. Any future questions, please feel free to post and I 
will do my best to help.


Best regards,
Ji Zhou (v-jzho@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Fri, 19 Sep 2008 10:53:50 GMT   author:   (Ji Zhou [MSFT])

Re: change the ribbon menu   
You are brilliant - THANK YOU!


On Fri, 19 Sep 2008 10:53:50 GMT, v-jzho@online.microsoft.com ("Ji
Zhou [MSFT]") wrote:

>Hello Dave, 
> ...
>
>We can put both of the two tabs in the same customization xml file. We 
>define the getVisible callback function for these tabs. Whenever we want to 
>show/hide a tab, we call ribbon.Invalidate. So the getVisible callback will 
>be called, and we get chance to set the table's visible there.


david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
date: Fri, 19 Sep 2008 09:50:54 -0600   author:   David Thielen am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us