Jake
Jake

Reputation: 11430

How to Call Excel VBA functions from VSTO Application addin

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?

Upvotes: 1

Views: 2624

Answers (1)

to StackOverflow
to StackOverflow

Reputation: 124696

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);

Upvotes: 3

Related Questions