Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
snj snj is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
snj snj is offline
external usenet poster
 
Posts: 2
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Showing/Hiding Styles in Word 2007 Anne Microsoft Word Help 4 December 8th 08 03:53 PM
Showing/hiding sections of a Word document Rob Wahl Microsoft Word Help 2 April 22nd 08 12:37 AM
hiding the ribbon P. Zicari Microsoft Word Help 2 September 13th 07 01:03 PM
Automatic hiding/showing page breaks kbrad011 Page Layout 2 September 6th 07 12:11 AM
Hiding/showing a table with VBA AmandaH Microsoft Word Help 2 July 13th 06 11:44 AM


All times are GMT +1. The time now is 01:45 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"