S
snj
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/library/bb421511(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/archi...ins-and-requestcomaddinautomationservice.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
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/library/bb421511(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/archi...ins-and-requestcomaddinautomationservice.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