求教:如何在Excel2000中调用自己编写的dll中的函数,就像Excel中调用内部的Max,Min等一样,可以参与单元格值的计算.
描述:
我看一些关于Excel97的资料中介绍说用REGISTER来注册DLL函数,然后用Call来调用,但在Excel2000中不能使用,想请教各位高手,有什么办法可以加载自己做的Dll.
解决方案1:
转别人的给你看,版权归别人
************************************************
你字用vc做的dll
extern "C" int _stdcall GetTagInfoString(LPCTSTR strRMsg,/*[in]*/
short *intCarrierClass,/*[out]*/
BSTR* strCargo/*[out]*/)
VB:
Public Declare Function GetTagInfoString Lib "CargoDLL.dll" _
(ByVal strRMsg As String, intCarrierClass As Integer, strCargo As String) As Long
调用后记得用StrConv(strCargo, vbFromUnicode)。。
Private Declare Sub SourceMake Lib "SourceMake.dll" (str As Any, src As
Variant)
Private Sub Command1_Click()
Dim src As Variant
Dim str As String
str = "100000"
Dim b() As Byte
b = StrConv(str, vbFromUnicode)
ReDim Preserve b(UBound(b) + 1)
b(UBound(b)) = 0
On Error GoTo EX
src = String(255, vbNullChar)
Call SourceMake(b(0), src )
MsgBox src
EX:
MsgBox Err.Description
End Sub
跟VB里面调用一样,或者说跟EXCEL中调用WINAPI一样
可参考
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/modcore/html/deovrcallingdllfunctions.asp
比如:
Declare Function
ShellExecute Lib _ "shell32.dll" Alias "ShellExecuteA ...