Solved

VBA/VSTO Fire VB.net code using VBA

Posted on 2013-01-25
2
375 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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