DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 02 Jul 2007 01:09:33 -0700,    posted on: microsoft.public.dotnet.framework.interop        back       

Thread Index
  1    unknown
          2    G Himangi
          3    unknown


Using .NET COM object in VBA fails   
I have a problem using .NET assemblies by their COM interface from
VBA. Everything works well on my machine, but on a different PC I
allways get the error message: "Automation  error. The system cannot
find the file specified."
Creating the .NET component in VBA fails when it has been built with
VS 2005. When I build it with VS 2003 it works on my machine and also
on the other machine. Creating the component in a VB6 executable works
well in all combinations (VS2003 and VS2005 on both machines). I see
this problem only with VBA.

Both machines are running Office 2003, VBA: 6.4.9972
My machine has VS 2003 and VS 2005 installed, the other machine has VS
2003 and .NET 2.0 installed.

My VB.NET sample class:

Imports System.Runtime.InteropServices

<ComClass("1D4A6BFA-71B0-4841-AC0E-55514AD14DEA",
"FEDCBAB4-7BD5-4272-8E9B-91CB81ECC350")> _
Public Class SimpleTestClass
  Public Sub New()
    ' we do nothing special here
  End Sub

  Public Sub Method1()
    MsgBox("Method1 called")
  End Sub

  Public Sub Method2(ByVal val As Integer)
    MsgBox("Method2 called, value: " + val.ToString())
  End Sub
End Class

In the assembly information dialog I've checked "Make assembly COM-
Visible"
On the "Compile" tab I've also checked "Register for COM interop"

When I try to call this object form a VBA macro like this one:

Public Sub DoTheTest()
  Dim oTest As SimpleTestClass
  Set oTest = New SimpleTestClass
  oTest.Method1
End Sub

I get the error message when executing the line "Set ... ".
The typelib seems to be well registered, because I can see the
SimpleTestClass on the reference tab and could also see all the
methods in the VBA intellisense.
Any ideas?
Date:Mon, 02 Jul 2007 01:09:33 -0700   Author:  

Re: Using .NET COM object in VBA fails   
I am guessing the problem is because of mismatched versions of the .Net 
runtime. The VBA engine might have already loaded v1.1 of the runtime and so 
it is unable to load your object created with .Net 2.0

--------- 
- G Himangi,   Sky Software       http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell 
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs 
rapidly in .Net
--------- 




 wrote in message 
news:1183363773.458659.284620@k79g2000hse.googlegroups.com...

>I have a problem using .NET assemblies by their COM interface from
> VBA. Everything works well on my machine, but on a different PC I
> allways get the error message: "Automation  error. The system cannot
> find the file specified."
> Creating the .NET component in VBA fails when it has been built with
> VS 2005. When I build it with VS 2003 it works on my machine and also
> on the other machine. Creating the component in a VB6 executable works
> well in all combinations (VS2003 and VS2005 on both machines). I see
> this problem only with VBA.
>
> Both machines are running Office 2003, VBA: 6.4.9972
> My machine has VS 2003 and VS 2005 installed, the other machine has VS
> 2003 and .NET 2.0 installed.
>
> My VB.NET sample class:
>
> Imports System.Runtime.InteropServices
>
> <ComClass("1D4A6BFA-71B0-4841-AC0E-55514AD14DEA",
> "FEDCBAB4-7BD5-4272-8E9B-91CB81ECC350")> _
> Public Class SimpleTestClass
>  Public Sub New()
>    ' we do nothing special here
>  End Sub
>
>  Public Sub Method1()
>    MsgBox("Method1 called")
>  End Sub
>
>  Public Sub Method2(ByVal val As Integer)
>    MsgBox("Method2 called, value: " + val.ToString())
>  End Sub
> End Class
>
> In the assembly information dialog I've checked "Make assembly COM-
> Visible"
> On the "Compile" tab I've also checked "Register for COM interop"
>
> When I try to call this object form a VBA macro like this one:
>
> Public Sub DoTheTest()
>  Dim oTest As SimpleTestClass
>  Set oTest = New SimpleTestClass
>  oTest.Method1
> End Sub
>
> I get the error message when executing the line "Set ... ".
> The typelib seems to be well registered, because I can see the
> SimpleTestClass on the reference tab and could also see all the
> methods in the VBA intellisense.
> Any ideas?
> 
Date:Tue, 3 Jul 2007 17:13:09 +0530   Author:  

Re: Using .NET COM object in VBA fails   
Thank you, this solved the problem!
I need a "Exel.exe.config" file, where I have to specify to use
the .NET 2.0 runtime.


On 3 Jul., 13:43, "G Himangi"  wrote:

> I am guessing the problem is because of mismatched versions of the .Net
> runtime. The VBA engine might have already loaded v1.1 of the runtime and so
> it is unable to load your object created with .Net 2.0
>
> ---------
> - G Himangi,   Sky Software      http://www.ssware.com
> Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
> Browsing Functionality For Your App (.Net & ActiveX Editions).
> EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
> EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
> rapidly in .Net
> ---------
>
>  wrote in message
>
> news:1183363773.458659.284620@k79g2000hse.googlegroups.com...
>
>
>
> >I have a problem using .NET assemblies by their COM interface from
> > VBA. Everything works well on my machine, but on a different PC I
> > allways get the error message: "Automation  error. The system cannot
> > find the file specified."
> > Creating the .NET component in VBA fails when it has been built with
> > VS 2005. When I build it with VS 2003 it works on my machine and also
> > on the other machine. Creating the component in a VB6 executable works
> > well in all combinations (VS2003 and VS2005 on both machines). I see
> > this problem only with VBA.
>
> > Both machines are running Office 2003, VBA: 6.4.9972
> > My machine has VS 2003 and VS 2005 installed, the other machine has VS
> > 2003 and .NET 2.0 installed.
>
> > My VB.NET sample class:
>
> > Imports System.Runtime.InteropServices
>
> > <ComClass("1D4A6BFA-71B0-4841-AC0E-55514AD14DEA",
> > "FEDCBAB4-7BD5-4272-8E9B-91CB81ECC350")> _
> > Public Class SimpleTestClass
> >  Public Sub New()
> >    ' we do nothing special here
> >  End Sub
>
> >  Public Sub Method1()
> >    MsgBox("Method1 called")
> >  End Sub
>
> >  Public Sub Method2(ByVal val As Integer)
> >    MsgBox("Method2 called, value: " + val.ToString())
> >  End Sub
> > End Class
>
> > In the assembly information dialog I've checked "Make assembly COM-
> > Visible"
> > On the "Compile" tab I've also checked "Register for COM interop"
>
> > When I try to call this object form a VBA macro like this one:
>
> > Public Sub DoTheTest()
> >  Dim oTest As SimpleTestClass
> >  Set oTest = New SimpleTestClass
> >  oTest.Method1
> > End Sub
>
> > I get the error message when executing the line "Set ... ".
> > The typelib seems to be well registered, because I can see the
> > SimpleTestClass on the reference tab and could also see all the
> > methods in the VBA intellisense.
> > Any ideas?- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
Date:Wed, 04 Jul 2007 05:34:57 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us