我看着其他职位,但没有找到解决方案。
我试图用我的VBA代码创建,而无需添加参考C#DLL。
在我的VBA代码,我宣布:
Public Declare Function message Lib "path_to_my_dll" _
(ByVal message As String) As String
Sub Test()
Dim hello As String
hello = message("hi!!")
Debug.Print hello
End Sub
我得到一个错误说切入点我的DLL找不到。
C#代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace DLLImport
{
public class Class1
{
[DllImport("DLLImport", EntryPoint = "Run")]
extern string Run(string message)
{
return message;
}
}
}
预先感谢您的帮助!!
您可能需要使用InteropServices做一个COM DLL可见
using System.Runtime.InteropServices;
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("your-GUID-1")]
public interface _Visible_Methods
{
//--------< _Visible_Methods >--------
//*visible COM Methods of this Control under Office,Excel, Word
string get_Hello();
//--------</ _Visible_Methods >--------
}
来源:https://codedocu.com/Net-Framework/Controls/COM-ActiveX/Create-C_hash_-COM-Control-for-Office?2382