Hi, what is the procedure to run macro stored in my addin from thisworkbook...
Is there any special way to do this?
Is there any thing i have to keep in mind when running macro stored in my addin?
Thanks for helping in advance.
You have many options :
OPTION 1
1- Change the Addin Project name from the default VBAProject to a different name to uniqually identify it via the VBE Properties window
2- Set a reference to the new addin project via the VBE tools - References window.
you can then run all the
Public macros in your addin
Something like this :
Where
MyAddin is the name of the Addin
Project (Changed as described above) and the Macro is the Addin macro to run.
The good thing about this method is that you gain the Intellsense functionality when writing code.The bad thing is that this approach could cause problems if the reference is missing.
OPTION2
Another way is to have the addin Macro declared as
Public and located in the addin
workbook module then you can call it something along these lines :
Code:
Dim oAddin As Workbook
Set oAddin = GetObject(AddIns("AddinName").FullName)
Call oAddin.Macro
where
AddinName is the name of the addin.
OPTION3
Yet another way is by using the Application
Run Method such as :
Code:
Application.Run ("AddinName.xla!Macro")
The Run Method allows you to flexibly run macros in
standard modules even
Private Macros so it is more flexible and no need for any references to be preset.
Maybe other options exist as well.
EDITED: In fact all the above remains true for calling Macros in other open workbooks not just in Addins.