Calling excel macro from VB 6 app problem

C

C. Johnson

I am posting this question for a co-worker but know enough of the problem to
be able to reply. Thanks for any help on this matter.

We have an Excel plugin (MyPlugin.xla) in the XLStart folder. We need to run
a public subroutine called MySub that is stored in the MyModule module from
a VB6 program. We tried the following:

Xapp.Application.Run "'MyPlugin.xla'!MyModule.MySub"

This results in the following error message:

Runtime error '1004': The macro 'MyPlugin.xla!MyModule.MySub' cannot be
found.

We've tried several combinations of syntax above with the following
statements with similar results:

Excel.AddIns.Add FileName:="C:\Program Files\Microsoft
Office\OFFICE11\XLStart\MyPlugin.xla"

AddIns("MyPlugin.xla").Installed = True

and

Xapp.Workbooks.Open FileName:="C:\Program Files\Microsoft
Office\OFFICE11\XLStart\MyPlugin.xla"

What is the correct way to run this macro?

Thanks,

David
 
T

Tom Ogilvy

You are correct, the addin has to be loaded (and it isn't by default if
Excel is opened through automation). Then you would use the Run command you
show.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top