Solved

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

Posted on 2012-04-09
6
447 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
ID: 37826323
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
ID: 37826411
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
ID: 37830360
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
ID: 37831517
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
ID: 37835164
Good, please delete this question.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 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

17 Experts available now in Live!

Get 1:1 Help Now