Solved

VBA/VSTO Fire VB.net code using VBA

Posted on 2013-01-25
2
373 Views
Last Modified: 2013-01-29
Hi

I have a VB.net Add-in  that is open at the same time as an Excel file containing macros. I need to run code in VBA to open a form on the VB.net side. What clever way can this be done by firing an event in VBA that the VB.net side picks up in order to run it's code.
0
Comment
Question by:murbro
2 Comments
 
LVL 11

Accepted Solution

by:
jkpieterse earned 500 total points
ID: 38818340
One way is to have the .NET addin create a (hidden) commandbar with a button. You can then use the commandbarbuttons's execute method to start code in the .NET addin.

Here is some code I used for an add-in I have:

Public Sub LaunchPrecedents()
    Dim octl As CommandBarControl
    For Each octl In Application.CommandBars("Cell").Controls
        If octl.Tag = "RefTreeAnalyser" Then
            octl.Controls(1).Execute
        End If
    Next
End Sub
0
 

Author Closing Comment

by:murbro
ID: 38831374
Thanks very much
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 code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

911 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

23 Experts available now in Live!

Get 1:1 Help Now