 |
|
 |
Found an answer to my own question. You just need to install this Office update:
http://www.microsoft.com/downloads/details.aspx?FamilyId=1B0BFB35-C252-43CC-8A2A-6A64D6AC4670&displaylang=en
This will only work if the AddIn was developed with VS2005 and you're using Excel 2003 which is my case.
|
|
|
|
 |
|
 |
Thanks very much for posting this. I have been looking for some time with no joy for a way to use C# Express to build Excel Add-Ins and you have solved my problem.
What we are now missing is how to add the explanatory text to each function paramater that would come up if using the function wizard.
Is it possible to post how to do that please?
Many Thanks
-- modified at 8:27 Friday 26th October, 2007
Having now read through the comments on this site I see that you have to write an XLL not a DLL to do this.
|
|
|
|
 |
|
 |
Thanks G. V. Drimmelen for your nice document on creating UDF in C#. Based on your article i created a lot of UDF. Now I want to creat an other UDF like the following:- double MyAddition2(double arg1, double arg2) { Excel.Application appObject = getAllicationObject(); Excel.Range cell = appObject.ActiveCell; cell.Interior.ColorIndex = (object)20; return arg1 + arg2; } Besically, I want to color the cell where my UDF will be called. But the line "cell.Interior.ColorIndex = (object)20;" returns an exception (Exception from HRESULT: 0x800A03EC). How to overcome this? I checked the cell contains proper excel cell and cell.Worksheet.Name is also correct as it should be. Mousum Dutta
|
|
|
|
 |
|
 |
Hi
I created the add in and it works like a charm in my machine
but then I need to move the dll file to another machine and install it on the excel there,for which i tried the regasm cmd and it wudnt work, the cmd gives me errors on cmd prompt
can someone pls pls help me out
thanks
a
|
|
|
|
 |
|
 |
Set ComVisible property to "true" in AssemblyInfo.cs file.
|
|
|
|
 |
|
 |
Hi, I need some direction here.
I followed Govert van Drimmelen's original sample and got everything ok until I tried to insert the function ADD2. I do not see it. I got the add-in step correctly by using automation add-in. I also asked another friend try it on his PC, same problem. How does everyone else get around this prolem?
I use Excel 2003 and VS 2005.
Thank
Larry
|
|
|
|
 |
|
 |
Hi Larry,
I now use ExcelDna (http://groups.google.com/group/exceldna) to create Excel user-defined functions in .Net.
But I can suggest one possible reason for your problem. If you compile with .Net 2.0 (thus VS 2005) your assembly might not load because version 1.1 of the runtime is loaded into the Excel process. To work around this, you need to delete a registry key, or create an Excel.exe.config file that ensures the correct runtime is loaded, or install a patch for Excel. You can check the 'Getting Started' instructions for ExcelDna (http://groups.google.com/group/exceldna/web/getting-started-with-exceldna) for the details.
Please post back if this solves your problem.
Regards,
Govert
|
|
|
|
 |
|
 |
i dont know what i do wrong, i ticked it as ok for interop and i dont see it.
if i manually add it in excel itsays its not a COM server or something.
|
|
|
|
 |
|
 |
I had the same problem using VS2008 and Excel 2003. I solved it by changing [assembly: ComVisible( false )] to [assembly: ComVisible( true )] in AssemblyInfo.cs
modified on Tuesday, December 23, 2008 5:19 AM
|
|
|
|
 |
|
 |
I have used the code from the article to create an Excel addin. The addin is visible in the list of available ones. But when I use it in a worksheet, I am getting "REF!" error.
I am using home & student edition of Excel 2007.
Amey Joshi
|
|
|
|
 |
|
|
 |
|
 |
Hi everyone,
Is there any way to run a procedure (sub) instead of o function on Excel with this type of automation?
I'm trying to pop-up a form or populate a spreadsheet, can't see how to load the sub.
Thx for now.
Randal
|
|
|
|
 |
|
 |
Hi, I'm having the following problem. I wrote my add-in in VB.net and I've been able to see it as a automation in Excel, but even when I add it as a Automation it not recognizes my UDF and when I click it on the Add-in listbox it says that mscoree.dll is missing and if I want to delete the Add-in. Did anyone have the same problem and knows how to solve it? Here my code: <ClassInterface(ClassInterfaceType.AutoDual)> Public Class Funcs Public Function ADD2(ByVal a As Double, ByVal b As Double) As Double Return a + b End Function
<ComRegisterFunctionAttribute()> Public Shared Sub RegisterFunction(ByVal t As Type) Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable") End Sub <ComUnregisterFunctionAttribute()> Public Shared Sub UnregisterFunction(ByVal t As Type) Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable") End Sub End Class Randal Junior
|
|
|
|
 |
|
 |
I had the same problem, solved by creating a file Excel.exe.config file in C:\Program Files\Microsoft Office\OFFICE11 with the contents. <?xml version="1.0" ?> <configuration> <startup> <supportedRuntime version="v2.0.50727"/> </startup> </configuration>
|
|
|
|
 |
|
 |
It didn't solved my problem, this config file must be with the dll file or just in OFFICE11 folder?
When I use the regasm soft to register it I get the following registry keys:
[HKEY_CLASSES_ROOT\CLSID\{49D51C4B-4FE7-3563-8E7B-ED9875EE808F}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="ExcelAddinRandal.Funcoes"
"Assembly"="ExcelAddinRandal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a67d17f8440c6d3c"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///d:/ExcelAddinRandal.DLL"
[HKEY_CLASSES_ROOT\CLSID\{49D51C4B-4FE7-3563-8E7B-ED9875EE808F}\InprocServer32\1.0.0.0]
"Class"="ExcelAddinRandal.Funcoes"
"Assembly"="ExcelAddinRandal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a67d17f8440c6d3c"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///d:/ExcelAddinRandal.DLL"
thx for the help
Randal Junior
|
|
|
|
 |
|
 |
I had the same problem and found a solution on the web that worked for me:
To fix this we need to add the following to the end of the RegisterFunction
method:
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() +
"}\\InprocServer32");
key.SetValue("", @"C:\Windows\System32\mscoree.dll");
Oh, and the config file mentioned above is required for Excel 2002 to work with .Net 2.0 (it defaults to .Net 1.1) but is not required for Excel 2003.
-- modified at 15:02 Friday 20th April, 2007
|
|
|
|
 |
|
 |
Thx a lot... now it worked fine.... For other people: remember to look at the correct path of mscoree.dll. My VB.Net code became this: <ComRegisterFunctionAttribute()> _ Public Shared Sub RegisterFunction(ByVal t As Type) Dim key As Microsoft.Win32.RegistryKey Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\{" _ & t.GUID.ToString().ToUpper() & "}\Programmable") key = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\\{" _ & t.GUID.ToString().ToUpper() & "}\\InprocServer32") key.SetValue("", "C:\WINNT\System32\mscoree.dll") End Sub Randal
|
|
|
|
 |
|
 |
Ideally, you should use Environment.GetFolderPath(Environment.SpecialFolder.System) to get the reference to the C:\Windows\System32 folder.
|
|
|
|
 |
|
|
 |
|
 |
First of all i pay thanks to such a great site.
I have approached the following method to create and use the managed code
user defined functions for excel.
http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx
and code given by you in NAddin example.
Could someone please comment on how can we trap events for user defined
function (UDFs) calculation start and end?
i want to handle the event eg. i roughly give them name as UDFCalculation_start and UDFcalculation_end.
I am pretty new to automation add-ins, so please help me taking some example and fire events.
parm
|
|
|
|
 |
|
 |
Hi,
could someone plzz make efforts to solve my problem..
plzz its important.
parm
|
|
|
|
 |
|
 |
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
|
|
|
|
 |