I looked at other posts and couldn't find the solution.
I am trying to use C# dll I created in VBA code without having to add reference.
In my VBA code, I declared:
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
I get an error saying entry point for my dll couldn't be found.
The C# Code:
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;
}
}
}
Thank you in advance for your help!!
You might want to use InteropServices to make a COM Visible 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 >--------
}
Source: https://codedocu.com/Net-Framework/Controls/COM-ActiveX/Create-C_hash_-COM-Control-for-Office?2382
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.