Link to home
Start Free TrialLog in
Avatar of Walter Grimm
Walter Grimm

asked on

Office addin shared events - run event in other class as where object is defined

I am trying to create a simple outlook addin that reads and writes to the ribbon bar. I have bought the addin express tool, but somehow the addin has some tweaks, since it does not react like the normal VBA with events etc.

I am looking for a sample that would achieve the following,

in this sample i need to see how i can read and write values from a ribbon bar element, in one seperate class (in the addin express it only lets me call events in the main Addin class, i would like to have the call run in a seperate class)

in the sample, i would like to react to an event from an outlook ribbon item in one sperate class - SO i have a Event that gets triggered in a seperate class, so i dont fill up my base calss where the addinmodule resides

SO ia solution that does the following:
the element in the ribbon should be a drop down list,
In the ribbon add a button, when clicked it will read the value from the drop down box and trigger a sub in a seperate class file, than the addinmodule
Avatar of Walter Grimm
Walter Grimm

ASKER

I figured out that it must also add the shared to the public with events declaration of the object, just setting it shared in the properties of the designer was not enaugh, than i was able to write to object in the ribbon, wich than works.

Ever time i run the designer for the objects drop down in in Addin Express, it will delete the shared code from this object, so I need to add the  code "shared" for each object over and over:

OPEN: I would like to run an event of the click object outside of the designer code behind, this still triggers some errors, here is the line: the IRibbonControl and btnshowform.onclick are underlined red when i place the event handler in another class. I assume i am missing some basics.

    Public Shared Sub Btnshowform_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles btnshowform.OnClick
        showforms.ShowmyForm()
    End Sub
Avatar of Fabrice Lambert
Public Shared Sub Btnshowform_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles btnshowform.OnClick
Erm is this VB.Net ?
(to my knowledge, there is no such syntax with VBA).

You should change you question's tag, so .Net experts can find the question and answer.
Hi, I copied this from the class where the control elements are defined, there it works, when I copy it to another class it gives me errors, I need to set some global ref or something to the class in which the control resides and triggers the event.

I am using addin express, unfortunately they are not able to answer any questions for paid version
Still, it isn't VBA related.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.