读书人

【HELP】vba createobject不成功解决思

发布时间: 2012-09-22 21:54:54 作者: rapoo

【HELP】vba createobject不成功
一下我用C#写的测试代码:

C# code
using System;using System.Reflection;using System.Windows.Forms;[assembly:   AssemblyKeyFile( "C:\\Documents and Settings\\Administrator\\My Documents\\Downloads\\SimpleCLRHost_demo\\HelloMsgBox.snk")]namespace Ranjeet.SimpleCLRHost{    public class HelloHostDemo    {        public void Hi()         {        MessageBox.Show("YOO HOO from the Managed World!", "And now for this message");        }    }}


然后编译为DLL,接着使用regasm.exe 注册该DLL成功

一切成功后,最后开始在VBA中测试,打开EXCEL:

VB code
Public lngStatus As ObjectSub test()    On Error GoTo an_error    If lngStatus Is Nothing Then        lngStatus = CreateObject("Ranjeet.SimpleCLRHost.HelloHostDemo")    End If    an_error:End Sub


可恨的是CreateObject不成功,"Ranjeet.SimpleCLRHost.HelloHostDemo"的名称是无误的,请问哪位大虾帮帮忙,是不是我中间缺少了某个过程

[解决办法]
参考下面的内容:
http://blog.csdn.net/neohope/article/details/6086893

读书人网 >VB

热点推荐