1
votes

Seen a quite a few examples of calling VSTO functions from VBA, using Automation Add-In, COM Interop etc but not the other way round.

I have an Excel application VSTO addin that is only designed to work with only the one Excel workbook. This Excel workbook is a legacy workbook since office 2003 and contains many VBA code.

How can I call these VBA functions and subs from VSTO?

1

1 Answers

2
votes

You can call it using the Application.Run method. E.g.

ThisApplication.Run("MyVbaMacroName",
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);