I am getting the following error message reported by Excel 2003.
Run-time error '-2147024894 (80070002)';
File or assembly name ZZZ, or one of its dependencies, was not found.
Here is the VBScript in Excel:
Private Sub Workbook_Open()
Dim mgr As Object
Range("C2").Value = ""
Range("C3").Value = ""
Range("C4").Value = ""
Range("C5").Value = ""
Set mgr = CreateObject("ZZZ.X")
If Not mgr Is Nothing Then
Dim conn As String
conn = mgr.GetConnectionStrWithRole("...")
If Len(conn) > 0 Then
Range("C2").Value = mgr...
Range("C3").Value = mgr...
Range("C4").Value = mgr...
Range("C5").Value = conn
End If
Set mgr = Nothing
End If
End Sub
If I put the following code in test.vbs it works:
Sub Test()
Set mgr = CreateObject("ZZZ.X")
mgr.GetConnectionStrWithRole("...")
End Sub
call Test
If I put the following code in a 2.0 .Net Console App it works:
Module Module1
Sub Main()
Dim u As Object
Try
u = CreateObject("ZZZ.X")
Console.WriteLine("A......: {0}", u.....)
Console.WriteLine("B......: {0}", u.....)
Catch ex As Exception
Console.WriteLine("EXCEPT.......: {0}", ex.Message)
End Try
End Sub
End Module
The ZZZ.X is a 2.0 .Net ServiceComponent
X.cs as follows
namespace ZZZ
{
[Transaction(TransactionOption.Required),ComVisible(true)]
public sealed class X : System.EnterpriseServices.ServicedComponent
{
public X()
{
}
}
}
assembly.cs contains
...
[assembly: ComVisible(false)]
[assembly: ApplicationActivation(ActivationOption.Library)]
[assembly: ApplicationName("ZZZ")]
...
The registry contains the ZZZ.X and CLSID information. Anyone have any ideas why the Excel 2003 vbscript isn't able to create the COM object?