LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to call a VBA routine in an add-in from a VB app?

When you start excel through automation, addins are not loaded. You can
load your addin with this code posted by KeepItCool;

code from KeepItCool (Oct 21, 2004)
Sub LoadXLwithAddins()
Dim xl As Object
Dim ai As Object

Set xl = CreateObject("Excel.Application")

For Each ai In Application.AddIns
If ai.Installed Then
xl.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
Next

xl.Visible = True
Set xl = Nothing
End Sub

Once the addin in loaded, then you should be able to run a macro in it by
using the RUN command.

. . . Run "MyAddin.xla!SomeRoutine"
--
Regards,
Tom Ogilvy

"Camden" wrote in message
m...
I have an Excel XLA add-in, written in VBA: call it "MyAddin.xla". Say
it has a module "AModule" and a Public Sub called "SomeRoutine()". I
want to be able to write an app in VB that will start up Excel,
activate the add-in, and then call SomeRoutine().

I've been able to do the first couple parts of that: I can call up
Excel from a VB app, and then step through the AddIns collection, find
my add-in, and make sure .Installed = True. All well and good. I can
add a workbook, then a worksheet, then change the name of the
worksheet, no problems.

Problem is, I haven't a clue as to how to call SomeRoutine() from my
VB app. I have an Object, addinMine, that I set equal to the Addins
item named "MyAddin.xla". After that I've tried:

- addinMine.Commands.SomeRoutine
- addinMine.SomeRoutine
- appExcel.Run addinMine.FullName & "!SomeRoutine"
- appExcel.Run addinMine.FullName & "!Commands.SomeRoutine"

Yes, those last two only work for workbook macros, but I still had to
try.


I've dug around in the docs I have, and dug around using Google, but
no luck. Can any of you folks tell me how to do what I want to do?
Failing that, can anyone tell me why it cannot be done? Thanks for any
help you can offer.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub Routine Call From a Macro D. Jones Excel Discussion (Misc queries) 1 November 8th 07 11:01 PM
Call Center Management: How to calculate 'cost per call' Denniso6 Excel Discussion (Misc queries) 2 June 25th 06 05:01 PM
How to keep a Variable alive after a Call to Sub Routine Dennis Excel Discussion (Misc queries) 2 July 27th 05 10:57 PM
Call MS Word envelope printing routine? Richard[_28_] Excel Programming 0 April 27th 04 09:08 PM
Routine?? Zax Excel Programming 3 December 19th 03 05:50 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"