?
Solved

VBA/VSTO Fire VB.net code using VBA

Posted on 2013-01-25
2
Medium Priority
?
379 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
jkpieterse earned 2000 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:Murray Brown
ID: 38831374
Thanks very much
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

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