tr7

I know it's possible to run a macro from VSTO C# code but I was wondering what some of the ramifications of doing this might be. Basically, I have an existing vba macro which does some complex formatting and rather than rewrite it, because of time constraints, it might be better to just call it from C#. What are some of your thoughts Thanks.

Re: Visual Studio Tools for Office Execute VBA macro from VSTO

Cindy Meister

The main concern would be whether it might conflict with anything your VSTO project is doing. So you'd probably want to make sure the user can't run any other commands until the macro has finished. I believe Application.Run would be synchronous within the procedure that calls it. So you could, perhaps, set a "global" property that all other procedures check before executing before the Application.Run line, then reset it after that line...




Re: Visual Studio Tools for Office Execute VBA macro from VSTO

Denis BDA

Tr7,

Have you considered converting the vba code to VB.net code Under VS2005, Tools, Upgrade Visual Basic 6 Code there is a converter that I've found pretty useful. I'm not certain if it'll convert everything you're dealing with, but it may give you a good head start over rewriting it or trying to run it from VSTO.

The option isn't available under a C# project but I see little reason why you couldn't then use a 3rd party tool to convert the VB.net code to C#

Denis






Re: Visual Studio Tools for Office Execute VBA macro from VSTO

VigneshRamalingam

Hi

I have develope a tool which will take an excel 2003 file as input, Parse the VBA macro in it and will Generate an equivalent c# dll for the VBA macro. I thought of using VSTO and reflection. Can anyone help me how to proceed with.

Thanks

Vignesh.R