Einzelnen Beitrag anzeigen

Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#10

Re: Funktion aus DLL in Excel verwenden

  Alt 9. Sep 2007, 18:22
Hallo Jürgen,
nach dem ich die DLL ins system32 geschoben habe läuft es einwandfrei.

Dies sind die Funktionen, die die DLL exportiert
Delphi-Quellcode:
function TPMValue1(Year, Partner, Entity, Posnr, Bwa : PChar) : Double; stdcall;
function TPMValue2(Year,Partner, Entity, Posnr : PChar) : Double; stdcall;
function TPMValue3(Year, Entity , Posnr : PChar) : Double; stdcall;
function TPMValue4(Year, Entity, Posnr, Bwa : PChar) : Double; stdcall;
Die Paramer sind ausschließlich Strings

In Excel werden die Funktionen wie folgt importiert.
Code:
Public Declare Function TPMValue1 Lib "tpmdirect" (ByVal Year As String, ByVal Partner As String, ByVal Entity As String, ByVal Posnr As String, ByVal Bwa As String) As Double
Public Declare Function TPMValue2 Lib "tpmdirect" (ByVal Year As String, ByVal Partner As String, ByVal Entity As String, ByVal Posnr As String) As Double
Public Declare Function TPMValue3 Lib "tpmdirect" (ByVal Year As String, ByVal Entity As String, ByVal Posnr As String) As Double
Public Declare Function TPMValue4 Lib "tpmdirect" (ByVal Year As String, ByVal Entity As String, ByVal Posnr As String, ByVal Bwa As String) As Double

Function TPM_Value1(ByVal Year As String, ByVal Partner As String, ByVal Entity As String, ByVal Posnr As String, ByVal Bwa As String) As Double
  TPM_Value1 = TPMValue1(Year, Partner, Entity, Posnr, Bwa)
End Function

Function TPM_Value2(ByVal Year As String, ByVal Partner As String, ByVal Entity As String, ByVal Posnr As String) As Double
  TPM_Value2 = TPMValue2(Year, Partner, Entity, Posnr)
End Function

Function TPM_Value3(ByVal Year As String, ByVal Entity As String, ByVal Posnr As String) As Double
  TPM_Value3 = TPMValue3(Year, Entity, Posnr)
End Function


Function TPM_Value4(ByVal Year As String, ByVal Entity As String, ByVal Posnr As String, ByVal Bwa As String) As Double
  TPM_Value4 = TPMValue4(Year, Entity, Posnr, Bwa)
End Function
Da ich die importierten Funktionen nicht direkt in der Zelle verwenden kann (weiss nicht warum) habe ich mir eine VBA Wrapper-Funktion geschrieben. Geht wie geschmiert.

Was mir jetzt noch fehlt ist die Übergabe eines Strings aus der DLL ins Excel.
I come from outer space to save the human race
  Mit Zitat antworten Zitat