473,699 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create DLL in Visual Studio 2005 accessible by Excel 2002

I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains
custom functions. I believe I need to use COM interop to allow VBA code in
Excel 2002 to access it. I've studied everything I can find on COM Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint 2002,
however so I believe the Add-in is being correctly registered in the GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in Access.

I don't even care about the commandbar buttons for my purposes; I just want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...

Aug 4 '06 #1
10 8200
You have done more research into this than I have, but let's start with
the basics.

Are you able to add a reference to your COM object using the "Add
Reference" dialog in the Excel/Visual Basic editor's Tools menu?

adm

Steve wrote:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains
custom functions. I believe I need to use COM interop to allow VBA code in
Excel 2002 to access it. I've studied everything I can find on COM Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint 2002,
however so I believe the Add-in is being correctly registered in the GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in Access.

I don't even care about the commandbar buttons for my purposes; I just want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...
Aug 4 '06 #2


Ok. Super simplistically, here's a complete C# COM-visible class library

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.Reflecti on;

[assembly: ComVisible(true )]
[assembly: Guid("37496b5c-462a-4547-b57e-d9063256e443")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVer sion("1.0.0.0")]

namespace ExcelFunctions
{

[ClassInterface( ClassInterfaceT ype.AutoDual)]
public class Functions
{
public double Add(double a, double b)
{
return a + b;
}
}
}

Create a DLL project in VS2005, paste this code, sign it,build it, GAC it
and then register it for COM interop with regasm.exe.
Then from an Excel macro set a reference to the library (this gives you
intellisense) and use it:
Private Sub Worksheet_Selec tionChange(ByVa l Target As Range)

Dim f As ExcelFunctions. Functions
Set f = CreateObject("E xcelFunctions.F unctions")

MsgBox f.Add(1, 2)

End Sub
This same VBScript can be used to test the COM library from a .vbs file too.

David

CreateObject("M yComponent.MyCl ass)
"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:CE******** *************** ***********@mic rosoft.com...
>I am trying to create a DLL in Visual Studio 2005-Visual Basic that
contains
custom functions. I believe I need to use COM interop to allow VBA code
in
Excel 2002 to access it. I've studied everything I can find on COM
Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even
these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using
Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint 2002,
however so I believe the Add-in is being correctly registered in the GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in
Access.

I don't even care about the commandbar buttons for my purposes; I just
want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...

Aug 4 '06 #3
Yes, I can add a reference to it. If I do that then define a new object like:

Dim o As MyCOMAddin.Conn ect

The VBA Editor recognizes the object and 'intellisenses' the class. None of
the Public Subs are visible, though.

"ad*****@yahoo. com" wrote:
You have done more research into this than I have, but let's start with
the basics.

Are you able to add a reference to your COM object using the "Add
Reference" dialog in the Excel/Visual Basic editor's Tools menu?

adm

Steve wrote:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains
custom functions. I believe I need to use COM interop to allow VBA code in
Excel 2002 to access it. I've studied everything I can find on COM Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint 2002,
however so I believe the Add-in is being correctly registered in the GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in Access.

I don't even care about the commandbar buttons for my purposes; I just want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...

Aug 4 '06 #4
Thank you for your reply, David.

After following the steps from your post, upon changing the selection in
Excel I get the following error message box (which is the error I've seen in
my other attempts):

Run-time error '-2147014894 (80070002)'

File or assembly name ExcelFunctions, or one of its dependencies, was not
found.

If I click the debug button, the

Set f = CreateObject("E xcelFunctions.F unctions")

line is highlighted.

To verify that I followed your post correctly, here are the steps I took:

1) Started Visual Studio 2005 and started a New Visual C# Class Library
Project. I assigned it the name ExcelFunctions.

2) in the Class1.cs file I replaced all the auto-generated code with a copy
& paste of the code in your post.

3) I removed the '[assembly' portions from the Class1.cs file and updated
the entries in the AssemblyInfo.cs file with those from your post, except I
retained the Guid generated by Visual Studio.

4) On the 'Signing' tab of the the Project Properties page, I checked the
"Sign the assembly" box and named the key file "ExcelFunctions .snk"

5) I built the project.

6) From the project directory where the .dll was located, I ran
"gacutil -i ExcelFunctions. dll"

7) From the project directory where the .dll was located, I ran
"regasm ExcelFunctions. dll /tlb"

8) I started Excel 2002 with a new blank workbook.

9) In the VBA Editor, I added a reference to "ExcelFunctions ". I then copy
and pasted your code into Book1 - Sheet1 (Code)

10) On selecting a new cell in Excel, the error appears.

After this, I uninstalled the .dll from the GAC, re-ran 'regasm' because I
thought it was supposed to be added to the registry first, then re-ran
'gacutil' with the same result in Excel.

Please comment on any corrections you have or any insight you can provide.

Thank you,

Steve
"David Browne" wrote:
>

Ok. Super simplistically, here's a complete C# COM-visible class library

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.Reflecti on;

[assembly: ComVisible(true )]
[assembly: Guid("37496b5c-462a-4547-b57e-d9063256e443")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVer sion("1.0.0.0")]

namespace ExcelFunctions
{

[ClassInterface( ClassInterfaceT ype.AutoDual)]
public class Functions
{
public double Add(double a, double b)
{
return a + b;
}
}
}

Create a DLL project in VS2005, paste this code, sign it,build it, GAC it
and then register it for COM interop with regasm.exe.
Then from an Excel macro set a reference to the library (this gives you
intellisense) and use it:
Private Sub Worksheet_Selec tionChange(ByVa l Target As Range)

Dim f As ExcelFunctions. Functions
Set f = CreateObject("E xcelFunctions.F unctions")

MsgBox f.Add(1, 2)

End Sub
This same VBScript can be used to test the COM library from a .vbs file too.

David

CreateObject("M yComponent.MyCl ass)
"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:CE******** *************** ***********@mic rosoft.com...
I am trying to create a DLL in Visual Studio 2005-Visual Basic that
contains
custom functions. I believe I need to use COM interop to allow VBA code
in
Excel 2002 to access it. I've studied everything I can find on COM
Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even
these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using
Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint 2002,
however so I believe the Add-in is being correctly registered in the GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in
Access.

I don't even care about the commandbar buttons for my purposes; I just
want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...


Aug 4 '06 #5
If you save these two lines

Set f = CreateObject("E xcelFunctions.F unctions")
MsgBox f.Add(1, 2)

into a file called test.vbs and run it, does it work?

You see the reference in the Excel Macro box, so you're really close.

Does the reg key
HKEY_CLASSES_RO OT\ExcelFunctio ns.Functions
exit?

David

"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:33******** *************** ***********@mic rosoft.com...
Thank you for your reply, David.

After following the steps from your post, upon changing the selection in
Excel I get the following error message box (which is the error I've seen
in
my other attempts):

Run-time error '-2147014894 (80070002)'

File or assembly name ExcelFunctions, or one of its dependencies, was not
found.

If I click the debug button, the

Set f = CreateObject("E xcelFunctions.F unctions")

line is highlighted.

To verify that I followed your post correctly, here are the steps I took:

1) Started Visual Studio 2005 and started a New Visual C# Class Library
Project. I assigned it the name ExcelFunctions.

2) in the Class1.cs file I replaced all the auto-generated code with a
copy
& paste of the code in your post.

3) I removed the '[assembly' portions from the Class1.cs file and updated
the entries in the AssemblyInfo.cs file with those from your post, except
I
retained the Guid generated by Visual Studio.

4) On the 'Signing' tab of the the Project Properties page, I checked the
"Sign the assembly" box and named the key file "ExcelFunctions .snk"

5) I built the project.

6) From the project directory where the .dll was located, I ran
"gacutil -i ExcelFunctions. dll"

7) From the project directory where the .dll was located, I ran
"regasm ExcelFunctions. dll /tlb"

8) I started Excel 2002 with a new blank workbook.

9) In the VBA Editor, I added a reference to "ExcelFunctions ". I then
copy
and pasted your code into Book1 - Sheet1 (Code)

10) On selecting a new cell in Excel, the error appears.

After this, I uninstalled the .dll from the GAC, re-ran 'regasm' because I
thought it was supposed to be added to the registry first, then re-ran
'gacutil' with the same result in Excel.

Please comment on any corrections you have or any insight you can provide.

Thank you,

Steve
"David Browne" wrote:
>>

Ok. Super simplistically, here's a complete C# COM-visible class library

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.Reflecti on;

[assembly: ComVisible(true )]
[assembly: Guid("37496b5c-462a-4547-b57e-d9063256e443")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVer sion("1.0.0.0")]

namespace ExcelFunctions
{

[ClassInterface( ClassInterfaceT ype.AutoDual)]
public class Functions
{
public double Add(double a, double b)
{
return a + b;
}
}
}

Create a DLL project in VS2005, paste this code, sign it,build it, GAC it
and then register it for COM interop with regasm.exe.
Then from an Excel macro set a reference to the library (this gives you
intellisense ) and use it:
Private Sub Worksheet_Selec tionChange(ByVa l Target As Range)

Dim f As ExcelFunctions. Functions
Set f = CreateObject("E xcelFunctions.F unctions")

MsgBox f.Add(1, 2)

End Sub
This same VBScript can be used to test the COM library from a .vbs file
too.

David

CreateObject(" MyComponent.MyC lass)
"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:CE******* *************** ************@mi crosoft.com...
>I am trying to create a DLL in Visual Studio 2005-Visual Basic that
contains
custom functions. I believe I need to use COM interop to allow VBA
code
in
Excel 2002 to access it. I've studied everything I can find on COM
Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even
these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using
Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint
2002,
however so I believe the Add-in is being correctly registered in the
GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or
Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in
Access.

I don't even care about the commandbar buttons for my purposes; I just
want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...



Aug 4 '06 #6
David,

The "test.vbs" script works fine. Also, the registry key

HKEY_CLASSES_RO OT\ExcelFunctio ns.Functions

does exist.

Are there other references I need to add in the Excel VBA Editor?

Again, thank you for your help.

Steve

"David Browne" wrote:
If you save these two lines

Set f = CreateObject("E xcelFunctions.F unctions")
MsgBox f.Add(1, 2)

into a file called test.vbs and run it, does it work?

You see the reference in the Excel Macro box, so you're really close.

Does the reg key
HKEY_CLASSES_RO OT\ExcelFunctio ns.Functions
exit?

David

"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:33******** *************** ***********@mic rosoft.com...
Thank you for your reply, David.

After following the steps from your post, upon changing the selection in
Excel I get the following error message box (which is the error I've seen
in
my other attempts):

Run-time error '-2147014894 (80070002)'

File or assembly name ExcelFunctions, or one of its dependencies, was not
found.

If I click the debug button, the

Set f = CreateObject("E xcelFunctions.F unctions")

line is highlighted.

To verify that I followed your post correctly, here are the steps I took:

1) Started Visual Studio 2005 and started a New Visual C# Class Library
Project. I assigned it the name ExcelFunctions.

2) in the Class1.cs file I replaced all the auto-generated code with a
copy
& paste of the code in your post.

3) I removed the '[assembly' portions from the Class1.cs file and updated
the entries in the AssemblyInfo.cs file with those from your post, except
I
retained the Guid generated by Visual Studio.

4) On the 'Signing' tab of the the Project Properties page, I checked the
"Sign the assembly" box and named the key file "ExcelFunctions .snk"

5) I built the project.

6) From the project directory where the .dll was located, I ran
"gacutil -i ExcelFunctions. dll"

7) From the project directory where the .dll was located, I ran
"regasm ExcelFunctions. dll /tlb"

8) I started Excel 2002 with a new blank workbook.

9) In the VBA Editor, I added a reference to "ExcelFunctions ". I then
copy
and pasted your code into Book1 - Sheet1 (Code)

10) On selecting a new cell in Excel, the error appears.

After this, I uninstalled the .dll from the GAC, re-ran 'regasm' because I
thought it was supposed to be added to the registry first, then re-ran
'gacutil' with the same result in Excel.

Please comment on any corrections you have or any insight you can provide.

Thank you,

Steve
"David Browne" wrote:
>

Ok. Super simplistically, here's a complete C# COM-visible class library

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.Reflecti on;

[assembly: ComVisible(true )]
[assembly: Guid("37496b5c-462a-4547-b57e-d9063256e443")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVer sion("1.0.0.0")]

namespace ExcelFunctions
{

[ClassInterface( ClassInterfaceT ype.AutoDual)]
public class Functions
{
public double Add(double a, double b)
{
return a + b;
}
}
}

Create a DLL project in VS2005, paste this code, sign it,build it, GAC it
and then register it for COM interop with regasm.exe.
Then from an Excel macro set a reference to the library (this gives you
intellisense) and use it:
Private Sub Worksheet_Selec tionChange(ByVa l Target As Range)

Dim f As ExcelFunctions. Functions
Set f = CreateObject("E xcelFunctions.F unctions")

MsgBox f.Add(1, 2)

End Sub
This same VBScript can be used to test the COM library from a .vbs file
too.

David

CreateObject("M yComponent.MyCl ass)
"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:CE******** *************** ***********@mic rosoft.com...
I am trying to create a DLL in Visual Studio 2005-Visual Basic that
contains
custom functions. I believe I need to use COM interop to allow VBA
code
in
Excel 2002 to access it. I've studied everything I can find on COM
Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even
these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using
Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint
2002,
however so I believe the Add-in is being correctly registered in the
GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or
Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in
Access.

I don't even care about the commandbar buttons for my purposes; I just
want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...



Aug 5 '06 #7
Steve... this is NOT a straight forward issue at all.

I have a sample VB (2003) app with written step-by-step documentation to do
this. Credit for this does not reside with me, but a sharp software support
guy at MS.

If you wish, e-mail me at

fbachman "at" landenshra dot com,

and I can send you what I have. It is involved enough that I wouldn't even
start by trying to post the communication here. I am happy to share what I
have. Please note, however, it os for VS.Net 2003, but I am SURE that
porting this to 2005 wouldn't involve a lot of pain.

--
Grumpy Aero Guy

"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:CE******** *************** ***********@mic rosoft.com...
>I am trying to create a DLL in Visual Studio 2005-Visual Basic that
contains
custom functions. I believe I need to use COM interop to allow VBA code
in
Excel 2002 to access it. I've studied everything I can find on COM
Interop
and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site
relating to COM add-ins, .NET and Office XP but am unable to get even
these
working in Excel 2002 or Word 2002.

I've installed the Office XP PIA's; I have Office XP SP3 installed; I'm
developing on a Windows XP Pro SP2 system.

Specifically the article, "How To Build an Office COM Add-in by Using
Visual
Basic .NET" located at http://support.microsoft.com/kb/302896/, doesn't
function in Excel 2002. It does work in Access 2002 and PowerPoint 2002,
however so I believe the Add-in is being correctly registered in the GAC.

When I start Excel, I get no 'connect' message and no button but excel
starts without error. I get no 'disconnect' message on closing Excel,
either. The behavior is the same in Word. Also, After the Word or Excel
starts, the
"HKEY_CURRENT_U SER\Software\Mi crosoft\Office\[OfficeApp]\Addins\[ProgID]\LoadBehavior"
registry entry changes from a 0x03 to a 0x02. This doesn't happen in
Access.

I don't even care about the commandbar buttons for my purposes; I just
want
to have access to my custom functions.

Any suggestions?

PS Some of the references I've researched are:

INFO: Develop Microsoft Office solutions with Visual Studio .NET
http://support.microsoft.com/kb/311452/EN-US/

Office XP Primary Interop Assemblies Known Issues
http://msdn.microsoft.com/library/de..._piaissues.asp

Walkthrough: Creating COM Objects with Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/x66s8zcd.aspx

COM Interoperabilit y in .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/e7a79b4y.aspx

And many others...

Aug 5 '06 #8

"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:97******** *************** ***********@mic rosoft.com...
David,

The "test.vbs" script works fine. Also, the registry key

HKEY_CLASSES_RO OT\ExcelFunctio ns.Functions

does exist.

Are there other references I need to add in the Excel VBA Editor?
No. Youv'e done everything else right.

My current hypothesis is that the 1.1 framework has been loaded by Excel
somehow.

To help diagnose assembly loading problems.

Assembly Binding Log Viewer (Fuslogvw.exe)
http://msdn2.microsoft.com/en-us/library/e74a18c4.aspx

Use Process Explorer to investigate the loaded dll's
http://www.sysinternals.com/Utilitie...sExplorer.html

See what version of mscorwks.dll is loaded by Excel.exe.
David
Aug 5 '06 #9
Well... how does version 1.1.4322 sound?

And, as I mentioned early on, Access and PowerPoint worked with the Add-in
samples. I just tried your DLL from a new form in Access and it works.
Would you believe the .NET Runtime version for Access is 2.0.50727?

What do you think?

"David Browne" wrote:
>
"Steve" <St***@discussi ons.microsoft.c omwrote in message
news:97******** *************** ***********@mic rosoft.com...
David,

The "test.vbs" script works fine. Also, the registry key

HKEY_CLASSES_RO OT\ExcelFunctio ns.Functions

does exist.

Are there other references I need to add in the Excel VBA Editor?

No. Youv'e done everything else right.

My current hypothesis is that the 1.1 framework has been loaded by Excel
somehow.

To help diagnose assembly loading problems.

Assembly Binding Log Viewer (Fuslogvw.exe)
http://msdn2.microsoft.com/en-us/library/e74a18c4.aspx

Use Process Explorer to investigate the loaded dll's
http://www.sysinternals.com/Utilitie...sExplorer.html

See what version of mscorwks.dll is loaded by Excel.exe.
David
Aug 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10738
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1 As Excel.Worksheet Set appExcel = New
0
1018
by: Jon Ley | last post by:
I have installed VS.NET 2005 (release, not beta) on my machine with Win2k SP4 and Office 2002. Now every time I open Word or Excel, the VS installer fires up. I tried repairing my Office installation, but after I did this VS would not work at all. So I repaired my VS installation and got back to my original problem with Word and Excel. My colleague has a similar config to myself, but on her machine Word and Excel open fine. She does...
4
2392
by: Skc | last post by:
We have a developer who has made an application in Visual Studio 2003 and this will not work in our version of Visual Studio 2002. Error message: Solution file loading error: The selected file is not a valid Visual Studio Solution file. When we try to load a project file, we get: Unable to read the project file. The project was created with a newer
13
3024
by: Mark Rae | last post by:
Hi, On Friday I attended the Microsoft EVO conference in London where they talked about Vista, Office 2007 and Exchange 2007 and how they all work together beautifully, how they were all "people-ready" etc... I asked a couple of questions about Visual Studio.NET on Vista, especially on 64-bit Vista, and they became *very* nervous... To cut a long story short, Microsoft will not support ANY version of Visual
0
1189
by: johnlim20088 | last post by:
Hi, Hi, currently I facing issues of migrate existing Visual Studio 2002 projects to Visual Studio 2005. I understood that there is no problem if we develop a new project from Visual Studio 2005. BUT we does FACING problems when try to migrate/convert from existing Visual Studio 2002 source to Visual Studio 2005 source. We does using existing convertion tools which Visual Studio 2005 provided. But encounter many problem. Any One...
0
1135
by: johnlim20088 | last post by:
Hi, Hi, currently I facing issues of migrate existing Visual Studio 2002 projects to Visual Studio 2005. I understood that there is no problem if we develop a new project from Visual Studio 2005. BUT we does FACING problems when try to migrate/convert from existing Visual Studio 2002 source to Visual Studio 2005 source. We does using existing convertion tools which Visual Studio 2005 provided. But encounter many problem. Any One...
1
3597
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in some files and work on it. Let say, I want add new page to web project named websiteOrder.sln, i will open websiteOrder.sln in my local computer, connected to websiteOrder.sln located in Visual Source Safe 6.0(source safe located in another...
11
2287
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I have seen the terms Visual Basic 2005 and VB.NET. It seems that sometimes they seem to be referring to the same thing but sometimes they are not. I also run into terms like VB9 and VB10.
7
2466
by: =?Utf-8?B?UHJhamFrdGE=?= | last post by:
We have an application build on Microsoft Visual Studio 2002 .Net 1.0 ie on 32 bit. Can we port the same application for .NET 2.0. Does .NET 2.0 is supported on Microsoft Visual studio 2002 ie for 32 bit application as .NET 2.0 is supported on Microsoft Visual studio 2005. And if yes How .NET 1.0 is to be upgraded to 2.0 on Microsoft visual studio 2002.
0
9187
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8894
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7776
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2360
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.