|
Henri Pellemans
Guest
|
Hi,
I have read the following topic:
http://www.add-in-express.com/forum/read.php?FID=5&TID=4167
I have a similar problem, and I do not understand the solution provided in that topic [at least I do not know what code I have to use, and where to put this code].
I will describe my problem as follows:
I have a lot of UDFs in a single XLL module. Now I would like to transfer some of these UDFs to a second XLL module [in the same solution]. I can add a XLLAdditionalModule to the project. But UDFs in this [second] module are not visible in Excel.
The UDFs in the second XLL module should also be available in the first XLL module [and the UDFs in the first XLL module should also be available in the second XLL module]
Can you help me by providing the VB.NET code and tell me where to put in the module[s]?
Best regards,
Henri
BTW I have the most recent versions of ADX 2010 Pro, Visual Studio 2010 Pro and Excel 2010 32-bit |
|
Posted 07 Oct, 2011 04:39:03
|
|
Top
|
|
Eugene Astafiev
Guest
|
Hi Henri,
Please note that you need to add your additional module to the Modules collection of your main XLL module in Visual Studio (see the Modules property of your XLL add-in module in the designer). That is all. Moreover, you don't need to use any code for this. Just add your second module manually at design-time. |
|
Posted 07 Oct, 2011 04:48:11
|
|
Top
|
|
Henri Pellemans
Guest
|
Hi Eugene,
I created an XLL add-in. In the solutions explorer I rightclick on XLLModule.vb and choose View Designer. In the properties window I go to Modules and then I add two times ADXXLLAdditionalModule with the names HenriModuleItem1 and HenriModuleItem2.
Then I rightclick on XLLModule.vb and I choose View Code.
The code in XLLModule.vb starts with Imports ... and then it shows:
<ComVisible(True)> _
Public Class XLLModule
Inherits AddinExpress.MSO.ADXXLLModule
Friend WithEvents HenriModuleItem1 As AddinExpress.MSO.ADXXLLAdditionalModuleItem
Friend WithEvents HenriModuleItem2 As AddinExpress.MSO.ADXXLLAdditionalModuleItem
I thought now I would have at least two and I even expect three XLL modules to put my UDFs in. I only see one module.
Before I started this topic I did the following:
I created an XLL add-in. I rightclick the project and choose Add Item. I can select either XLL Add-in Module [with description: Implements an XLL add-in Add-In Express based projects] or XLL Add-in Additional Module [with description: An additional COM add-in Module]. BTW the second description seems a bit strange to me. I added two add-ins by choosing XLL Add-in Module.
In this way I have three XLL Modules. The code shows:
In XLLModule.vb
<ComVisible(True)> _
Public Class XLLModule
Inherits AddinExpress.MSO.ADXXLLModule
In XLLModule1.vb
<ComVisible(True)> _
Public Class XLLModule1
Inherits AddinExpress.MSO.ADXXLLModule
In XLLModule2vb
<ComVisible(True)> _
Public Class XLLModule2
Inherits AddinExpress.MSO.ADXXLLModule
Now I can put my UDFs in three different modules. The problem arises that only the UDFs in the first Module are visible in Excel. And I can not use the UDFs of the first module in the second module. How do I refer to those UDFs?
Perhaps there is a very easy solution, but at this moment I don't get it.
Thanks for any help
Henri
PS the same happens when I choose XLL Add-in Additional Module instead of XLL Add-in Module. |
|
Posted 07 Oct, 2011 09:32:46
|
|
Top
|
|
Eugene Astafiev
Guest
|
Hi Henri,
1. Create a new XLL project.
2. Add a new item called XLL Add-in Additional Module.
3. Add the just added module to the Modules collection of your main XLL module.
It looks like we need to correct the description. I have added such record in our bug-tracking system under #3262. Thank you for pointing this to me!
FYI Anyway, I have sent a sample XLL add-in project to you. Please check out your Inbox. |
|
Posted 07 Oct, 2011 10:22:24
|
|
Top
|
|
Henri Pellemans
Guest
|
Hi Eugene,
Thank you for sending the sample XLL add-in. The bad news: it is in C#, that I am not familiar with. The good news: however, in the C# code I found that I not only have to add the module to the modules collection of the first XLL module. I also should refer to the ModuleProgID.
That said, I created 3 XLL modules, each with a function. All functions are now available in Excel. So far so good. Half of the problem is solved.
Now the remainder of my quest.
In XLL Module 2 I cannot use the UDFs I defined in XLL Module 1. And so on.
In my opinion it shouldn't be too difficult to do this.
How do I do this?
Best regards,
Henri |
|
Posted 07 Oct, 2011 12:38:07
|
|
Top
|
|
Henri Pellemans
Guest
|
If for once I may quote myself: "In my opinion it shouldn't be too difficult to do this".
Indeed, with some trial and error I solved the second part of the problem.
You can use the UDFs in the other XLL modules by referring to them as follows:
In XLLModule you add the code:
Imports MyXLLAddin1.XLLAdditionalModule1.XLLContainer
Imports MyXLLAddin1.XLLAdditionalModule2.XLLContainer
In XLLAdditionalModule1 you add the code
Imports MyXLLAddin1.XLLModule.XLLContainer
Imports MyXLLAddin1.XLLAdditionalModule2.XLLContainer
In XLLAdditionalModule2 you add the code
Imports MyXLLAddin1.XLLModule.XLLContainer
Imports MyXLLAddin1.XLLAdditionalModule1.XLLContainer
That's all.
Have a nice weekend,
Henri |
|
Posted 08 Oct, 2011 05:27:21
|
|
Top
|
|
Eugene Astafiev
Guest
|
Hi Henri,
Thank you for sharing your knowledge for other forum readers. Good luck with your add-in project! |
|
Posted 10 Oct, 2011 07:32:30
|
|
Top
|
|