Calling function from non-referenced add-in

E

erstewart00

Hello,

I've tried researching this topic but it is still not clear to me what
the correct syntax is, or if this is even possible.

Inside one sub, I would like to call a function in an add-in, but want
it to work if the add-in is not necessarily referenced in the project.

Ex.

str = fct_name( arg1, arg2)

This works if I reference the add-in.

str = (?)fct_name(arg1, arg2)

Isn't there a way to fully qualify this (?) such that the add-in does
not need to be specifically referenced?

Thanks for any input.
Eric
 
P

Peter T

s = Application.Run("myAddin.xla!fct_name", arg1, arg2)

Inclusion of the addin name may not be necessary if there's no ambiguity of
the procedure name in any open project.

Regards,
Peter T
 
E

erstewart00

s = Application.Run("myAddin.xla!fct_name", arg1, arg2)

Inclusion of the addin name may not be necessary if there's no ambiguity of
the procedure name in any open project.

Regards,
Peter T












- Show quoted text -

Thanks. This worked for me. Just curiuos how the syntax would change
if there was ambiguity and I had to specify the module as well?
 
P

Peter T

Regards,
Peter T

Thanks. This worked for me. Just curiuos how the syntax would
change if there was ambiguity and I had to specify the module as well?

Normally there shouldn't, couldn't, be any ambiguity of procedure names
within the same project. However you can qualify the procedure name with the
module name and a dot, eg

s = Application.Run("'myAddin.xla'!modName.fct_name", arg1, arg2)

Notice I've also embraced the wb name with apostrophes, necessary if certain
characters are present in the wb name, such as a space.

If you want to go the whole hog you could also include the path to ensure
the addin opens if not already
s = Application.Run("'c:\path\myAddin.xla'!.fct_name", arg1, arg2)

Obviously you'd need to know the path though you wouldn't necessarily need
to hard code it, as above.

Regards,
Peter T


Regards,
Peter T
 

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