Solved

VB.net Excel Add-in - call three toggle button clicks at once

Posted on 2012-04-09
6
432 Views
Last Modified: 2012-06-21
Hi. Below is the code behind three toggle button clicks on my Excel Add-In VB.net.
Each opens a CustomTaskPane. What code would I use to make all three happens simyltaneously behind a further ribbon button


    Private Sub ToggleButton1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles ToggleButton1.Click
        Globals.ThisAddIn.Where_TaskPane.Visible = _
    TryCast(sender, Microsoft.Office.Tools.Ribbon.RibbonToggleButton).Checked

    End Sub

    Private Sub ToggleButton__FROM_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles ToggleButton__FROM.Click
        Globals.ThisAddIn.From_TaskPane.Visible = _
    TryCast(sender, Microsoft.Office.Tools.Ribbon.RibbonToggleButton).Checked
    End Sub

    Private Sub ToggleButton_SELECT_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles ToggleButton_SELECT.Click
        Globals.ThisAddIn.Select_TaskPane.Visible = _
TryCast(sender, Microsoft.Office.Tools.Ribbon.RibbonToggleButton).Checked
    End Sub
0
Comment
Question by:murbro
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:Miguel Oz
Comment Utility
One possible solution:
Private Sub CommonButton_SELECT_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles ToggleButton_SELECT.Click
        ToggleButton1_Click( Button1, e)
        ToggleButton__FROM_Click(Button__FROM, e)
        ToggleButton_SELECT_Click(Button_SELECT , e)
    End Sub

Where Button1, Button__FROM and Button_SELECT are the instance of your buttons defined on your ribbon.

Note: Next time include the VSTO zone in your question, all Add-ins build with VS uses the VSTO technology and Interop.
0
 

Author Comment

by:murbro
Comment Utility
Hi

I get the following errors. Also the VSTO zone does not come up if you search for VSTO.1
0
 
LVL 35

Expert Comment

by:Miguel Oz
Comment Utility
Where are your buttons defined?
Can you provide your source code of the the ribbon and Add-in regarding the 3 buttons?
All you need to do is get a reference to the buttons - Most likely the ribbon button scopes are private , you need to make them public or create a public property for every button, so that you can access them from your ThisAddin.vb source code?)
Note: I do not have all your source code and do not know how you implement the buttons. I provide guidelines for the posted info only.
0
 

Author Comment

by:murbro
Comment Utility
Hi

I worked it out myself. All that was needed was what I provided. Thanks
        Globals.ThisAddIn.From_TaskPane.Visible = True
        Me.ToggleButton__FROM.Checked = True
        Globals.ThisAddIn.Select_TaskPane.Visible = True
        Me.ToggleButton_SELECT.Checked = True
        Globals.ThisAddIn.Where_TaskPane.Visible = True
        Me.ToggleButton1.Checked = True
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
Comment Utility
Good, please delete this question.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now