Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
VSTO Add-in: Hiding and Showing Word Ribbon Control from VBA
Hi there,
I have created a word vsto application add-in which allow user to hide and show word View tab on click of a button. This is similar to what this article does http://msdn.microsoft.com/hi-in/libr...11(en-us).aspx. After that I exposed an autmation object in the application add-in, so that VBA/VBA user can use the same to hide & show the View Tab. I refered Andrew's article, http://blogs.msdn.com/andreww/archiv...onservice.aspx. This URL talk about how to expose an object from VSTO add-in. But I have problem calling the Ribbon class's function inside my automation exposed object. Here is my code: Ribbon.XML ======== ?xml version="1.0" encoding="UTF-8"? customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" ribbon startFromScratch="false" tabs tab idMso="TabView" getVisible="ShowHideViewTab" / /tabs /ribbon /customUI Ribbon Class =============== public class MyRibbon : Office.IRibbonExtensibility { private bool showViewTabBool = true; public void ShowHideTab(bool showhide) { showViewTabBool = showhide; ribbon.Invalidate(); } public bool showViewTab(IRibbonControl control) { return showViewTabBool; } //other function goes here } Exposed Utility class for Customization ======================= [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] public class AddinUtilities : IUtilityClass { public void ShowHideTab(bool hideshow) { //MyRibbon ribbon = new MyRibbon() //ribbon.ShowHideTab(hideshow) HOW do I call the MyRibbon's ShowHideTab function here?? } } VBA Code =========================== Private Sub CommandButton_LateBinding_Click() Dim addin As Office.COMAddIn Dim automationObject As Object Set addin = Application.COMAddIns("MyRibbonCustomizer") Set automationObject = addin.Object automationObject.ShowHideTab(false) End Sub In Ribbon.xml I have a getvisble callback function which returns true when loaded. Then through VBA code I try to access the Exposed AddInUtility class and call ShowHideTab method. In this I wanted to call the showhideTab method in the Ribbon class and wanted to invalidate the controls so that the ribbon loads again and set the View tab's visible property to false. Thanks in advance, Snj |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
VSTO Add-in: Hiding and Showing Word Ribbon Control from VBA
Hey I got it worked by declaring a static MyRibbon variable and static
function in ThisAddIn class and accessing the same in my exposed class. "snj" wrote: Hi there, I have created a word vsto application add-in which allow user to hide and show word View tab on click of a button. This is similar to what this article does http://msdn.microsoft.com/hi-in/libr...11(en-us).aspx. After that I exposed an autmation object in the application add-in, so that VBA/VBA user can use the same to hide & show the View Tab. I refered Andrew's article, http://blogs.msdn.com/andreww/archiv...onservice.aspx. This URL talk about how to expose an object from VSTO add-in. But I have problem calling the Ribbon class's function inside my automation exposed object. Here is my code: Ribbon.XML ======== ?xml version="1.0" encoding="UTF-8"? customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" ribbon startFromScratch="false" tabs tab idMso="TabView" getVisible="ShowHideViewTab" / /tabs /ribbon /customUI Ribbon Class =============== public class MyRibbon : Office.IRibbonExtensibility { private bool showViewTabBool = true; public void ShowHideTab(bool showhide) { showViewTabBool = showhide; ribbon.Invalidate(); } public bool showViewTab(IRibbonControl control) { return showViewTabBool; } //other function goes here } Exposed Utility class for Customization ======================= [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] public class AddinUtilities : IUtilityClass { public void ShowHideTab(bool hideshow) { //MyRibbon ribbon = new MyRibbon() //ribbon.ShowHideTab(hideshow) HOW do I call the MyRibbon's ShowHideTab function here?? } } VBA Code =========================== Private Sub CommandButton_LateBinding_Click() Dim addin As Office.COMAddIn Dim automationObject As Object Set addin = Application.COMAddIns("MyRibbonCustomizer") Set automationObject = addin.Object automationObject.ShowHideTab(false) End Sub In Ribbon.xml I have a getvisble callback function which returns true when loaded. Then through VBA code I try to access the Exposed AddInUtility class and call ShowHideTab method. In this I wanted to call the showhideTab method in the Ribbon class and wanted to invalidate the controls so that the ribbon loads again and set the View tab's visible property to false. Thanks in advance, Snj |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Showing/Hiding Styles in Word 2007 | Microsoft Word Help | |||
Showing/hiding sections of a Word document | Microsoft Word Help | |||
hiding the ribbon | Microsoft Word Help | |||
Automatic hiding/showing page breaks | Page Layout | |||
Hiding/showing a table with VBA | Microsoft Word Help |