 |
|
 |
Hi,
I have followes the following example to create the automation add-ins.
http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx
This example work perfectly.
In the function given at the end of these document i have made a little bit
change.
public double NumberOfCells(object Range)
{
Excel.Range r = Range as Excel.Range;
foreach( Itshouldbecell c in Range)// want to know what type to use for in
place of Itshouldbecell
{
//want to know code for assigning value to the cell in the range
}
return r.Cells.Count;
}
eg. i write in the excel as : = NumberOfCells(b2:c3)
so i want to assign b2=2
b3=3
c2=4
c5=5.
Please help to find out the solution.
thanks.
parm
|
|
|
|
 |
|
 |
How can I make my application attach to multiple com application? I would like to provide a list of com applications installed on the user's pc.
For this reason I can't create a reference to the com object during runtime. It should be dynamic as per user selection. It could be an Excel, Word or other com application.
Summary
1) To get a list of all com applications available on the user's pc
2) To create a reference dynamical to what the user chose.
Thanks
|
|
|
|
 |
|
 |
hi... hello there...
for item #1: try in System.Management namespace
then
ManagementClass aMngt = new ManagementClass ("Win32_ClassicCOMClass");
search for "WMI queries and stuff" in this site...
though i forgot the actual link where i got a complete running code, sorry...
anyways, MSDN has a good example for ManagementClass...
-- modified at 19:26 Sunday 14th January, 2007
-- modified at 19:31 Sunday 14th January, 2007
|
|
|
|
 |
|
 |
Thanks for your update
Unfortunately I can't see the System.Management namespace. Do you have any ideas why? I have just installed .net framework v3
Thanks
|
|
|
|
 |
|
 |
hi...
sorry, for not mentioning in advance..
normally it wont be loaded as part of the default references in your project...
but you can add it anyways...
in the Solution Explorer window right-click on References and hit Add References...
a dialog will appear then go to .NET tab (1st tab) and scroll down till
you see System.Management then there you go...
|
|
|
|
 |
|
 |
I've declared the below code
colSWbemObjectSet = GetObject("winmgmts:").InstancesOf("Win32_COMApplicationClasses")
For Each objItem In colSWbemObjectSet
Debug.WriteLine(objItem.GroupComponent)
Next
and now i have a list of COM application id.
How can I use these IDs to create a dynamic reference?
By the way, thanks a lot for your help. I have learnt about something I never knew about.
Thanks
|
|
|
|
 |
|
 |
In C#, I dont know... Im sorry...
I think the bucket will end here for me...
C# is not a natural language for me...
I can only wager for the C++ approach in creating a dynamic instance of a COM given its CLSID...
I hope someone else could assist you in this department...
Lastly, I think were already Off-Topic for this particular thread
<Create an Automation Add-In for Excel using .NET>>...
I would not want to be kicked out of CP or anything...
so I got2go, c u sumwhere else... happy hunting...
|
|
|
|
 |
|
 |
Hi,
I've created Add-in automation for Excel thru VSTO 2005, all works fine, but it's not convenient to activate it manualy. Is there any register key or how to activate the add-in during excel louding?
Thanks
|
|
|
|
 |
|
 |
Yes there is a method (not via registry):
1) create an addin (xla) that is placed in a startup folder (e.g. )
2) create a standard module and add the following function
Sub addAutoAddin()
AddIns.Add Filename:= "YourAddinAsShownInAutomationAddins" (e.g. "NAddIn.Functions")
AddIns("YourAddinAsShownInAutomationAddins").Installed = True
End Sub
3) create a Workbook_open procedure in the Workbook class and add:
Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:00:05"), "addAutoAddin"
End Sub
This should do the job...
-regards,
Roland
|
|
|
|
 |
|
 |
Hi all, newbie here, need some serious help! Followed all the instruction created the NAddIn, built, and saw it on the Tool->Add-In, but not shown on the Insert -> Functions. Nothing!!! I used some suggested code to resolve the mscoree.dll problem already.
Using Excel 2003 and MicroSoft Visual c# 2005 Express Edition.
Any help is really appreciated.
|
|
|
|
 |
|
 |
Hi,
i just want to make a DLL that refer to an object which contains a lot of functions...
the code will be like this :
dim l_objTest as MyClass
public property Test as Myclass
get
return l_objTest
end get
set
l_objTest = Value
end set
When i compile this part of the code with the rest of you NaddIn, i have this :
I can use the Add2 function but i can't see the functions that are implemented in my object...
Is there anyway to do what i want to do ?
Regards
Shurka
|
|
|
|
 |
|
 |
Hi Shurka,
I'm not sure from your question what functions you expect to be exported to Excel. Properties are not likely to appear in Excel as user-defined functions, and there is nothing that would automatically make the functions in your Myclass appear.
I suggest you also have a look at my ExcelDna project(http://exceldna.typepad.com). However, I currently support only exporting of static functions (apart from the limited experimental support for Excel Services using the UdfClass and UdfMethod attributes). So for now you might need a wrapper class containing static functions that correspond to your class methods.
Regards,
Govert van Drimmelen
|
|
|
|
 |
|
 |
Hi,
thank you for answering me so quickly.
My problem is that i want to show in Excel functions that i have made in an another class that the one in the DLL. Let me explain this :
I have a class in a solution called MyClass1:
Myclass1
{
function1()
function2()
}
and in my dll class i have
MyDLLclass
{
private l_test as new MyClass1
public property test() as MyClass1
get
return l_test
end get
set(byval Value as MyClass1)
l_test = value
end set
end property
public function Add1(byval v1 as double, byval v2 as double) as double
return v1+v2
end function
}
When i compile this (i haven't copied the Com functions) it shows me in Excel the function Add1 and the Test... but not the functions function1 and function2... is there a way for me to get them ? Or is it impossible to made?
I hope i am clear enough
|
|
|
|
 |
|
 |
hi,maybe you can add Public void before them
www.artistsoft.com
|
|
|
|
 |
|
 |
Would you be kind enough to provide instructions on embedding the type library generated by regasm (I noticed you removed those instructions in July)?
Currently, as an automation add-in or a pure assembly, you can generate the type lib using the regasm /tlb. You cannot access the automation UDFs in cells directly without that tlb file in the same directory as the DLL file itself. This makes it annoying to have two files for redistribution (compared with just one in say ATL COM, where the tlb is embedded).
Is there anyway to do this with automation/.NET?
|
|
|
|
 |
|
 |
I developed a function add-in for excel that takes data from internet. When I try to refresh (in external data toolbar) the data in excel worksheet, no function is called. So, I have to refresh all the instances of that function selecting each cell and refreshing them by hand, that takes a lot of time.
Is there any way to refresh the whole excel worksheet when using .Net add-ins?
|
|
|
|
 |
|
 |
I can see this is an old question but the solution may be relevant for others.
There are in fact two solutions:
1) instead of pressing F9 / Shift+F9 you can force every cell to recalculate by pressing Ctrl+Alt+F9 or Shift+Ctrl+Alt+F9
2) append the following to your worksheet function: "+NOW()*0"
Hope that helps
|
|
|
|
 |
|
 |
Hello, Has anyone tried this in C++/CLI. I created a class library and added the following code:
using namespace System; using namespace System::Runtime::InteropServices; namespace ExcelFunction2 {
[ClassInterface(ClassInterfaceType::AutoDual)] public ref class Functions { public: Functions(){} double AddC(double v1, double v2) { return v1 + v2; } [ComRegisterFunctionAttribute] static void RegisterFunction(Type t) { Microsoft::Win32::RegistryKey^ root = Microsoft::Win32::Registry::ClassesRoot; root->CreateSubKey( "CLSID\\{" + t.GUID.ToString()->ToUpper() + "}\\Programmable"); } [ComUnregisterFunctionAttribute] static void UnregisterFunction(Type t) { Microsoft::Win32::RegistryKey^ root = Microsoft::Win32::Registry::ClassesRoot; root->DeleteSubKey( "CLSID\\{" + t.GUID.ToString()->ToUpper() + "}\\Programmable"); } }; } but it doesn't work. I got a little bit further by adding the following to the assembly info: [assembly:ComVisible(true)]; This makes ExcelFunction2.Functions appear in the list of automation objects in excel, but the function AddC is invisible. Yours David.
|
|
|
|
 |
|
 |
David,
I was wondering you you managed to workout the logic for this. If so would you please suggest how I might get around the problem. I am using Visual Studio 2005 and Excel 2003. After compiling I am able to add the DLL as an Automation Add-in. However, the Insert Function dialog does not list the function.
I would really appreciate some help.
Arnab
|
|
|
|
 |
|
 |
Hi Guys,
First of all, thanks for the great article!
The plugin works perfectly on the local machine, but when I relocate it to others it breaks down. I do register it with regasm, after that I do see it in the excel addin list, but when I am trying to reference it from spreadsheet - the functions are not in the list anymore.
Also, from VBA - I can see the namespace and classes, but when I try to reference them I get 'Automation Error'...
Your assistance is greately appreciated.
-igor
---------------------------
Igor R. Manassypov, M.Eng.,
imanassypov@ci.com
Network Architect
CI Investments
Toronto, Canada
---------------------------
|
|
|
|
 |
|
 |
OK I found the answer myself. Microsoft have a patch solution posted back in december that works for Office XP, but has not been included in the office xp update.
http://support.microsoft.com/kb/908002/en-us
I think the latest updates to office 2003 include it already so it is only needed for office XP only users using .net framework 2.0 add-ins.
Well it works for me anyway...what a pity clickonce deploy packages pre-requisite as a setup.exe and .msi which i don;t allow to download form my site...which was the whole point of choosing the .deploy/manifest solution check box in the click once options anyway..GO FIGURE.
Jeltz
|
|
|
|
 |
|
 |
I've just stumbled upon this solution myself and was about to post. Getting the latest office SP2 works just as well...
Have you tried achieving the same with vs03? I have the suspicion it will work on earlier patches.
---------------------------
Igor R. Manassypov, M.Eng.,
imanassypov@ci.com
Network Architect
CI Investments
Toronto, Canada
---------------------------
|
|
|
|
 |
|
 |
I don't know about you but it took me about 18 hours to find any reference to KB908002 anywhere; trouble was no error message and #NAME in excel is sooo generic. complicated by the fact my development machine is dual install office 10,11 and SP2 Office 11 automagically updates office 10 as well (go figure, thats why office XP clients will still need a manual patch!)
Even though supplied as VS2005 extra, in fact it is an office patch, so no reason you can;t distribute it from VS2003 (may have to do manually though, since the KB908002 download looks for VS2005 I think.
Much better just to advise Office 2003 users to update to SP2 from Microsoft office update, but alas NO alternative to redistrbute prerequisite yet for Office XP users as SP3 + latest extras show no sign of it.
Jeltz
|
|
|
|
 |
|
 |
Hi,
I had the same problem when developing the ExcelDna library that enables Excel add-ins and user-defined functions to be created using managed code.
The final version of .Net 2.0 added a registry entry the forces .Net 1.1 to be loaded into the Excel process, even when the first managed code is a .Net 2.0 assembly. The registry entry seems to suggest this only works for some versions of Excel, but I had problems in all versions I tried. I think they tried to add some backward compatibility for their VSTO or SiteServer stuff at the last minute, but it was a very, very bad idea. And it turns out to be a breaking change that is still (to my knowledge) completely undocumented.
The patch referred to above, or SP2, fixes it, or you can remove the registry entry, or you can create an excel.exe.config file that forces the .Net 2.0 runtime to be loaded. All these options are described in the ExcelDna 'Getting Started' at http://exceldna.typepad.com, together with a pointer to the newsgroup thread which told me all I know about the issue.
I have found deployment of the Automation Add-Ins to be pretty tricky, especially compared to ExcelDna Add-Ins (these work using the .xll glue).
Anyway, I hope this provides a bit more info.
Regards,
Govert
|
|
|
|
 |
|
 |
When i built the project and run excel i can't see the class there
|
|
|
|
 |