[fpc-pascal] Writing DLLs to by used in Excel VBA code

luciano de souza luchyanus at gmail.com
Tue Dec 15 01:52:22 CET 2015


The problem is solved. Actually, I didn't know that, in my Linux,
sharable libraries are only accessible from /usr/lib.

As I was trying to access a lib in another directory, Libreoffice was
not able to find it.

Regards,

Luciano

2015-12-11 17:15 GMT-02:00, luciano de souza <luchyanus at gmail.com>:
> Hello all,
>
> I want to use a DLL writen in Pascal to provide functions for a Excel VBA
> code:
>
> The example code of my DLL is:
> library CE;
> {$mode objfpc}
>
> uses
> Sysutils;
>
> function level(x1, x2: integer): integer; cdecl; export;
> begin
> result := x1 + 2*x2;
> end;
>
>
> exports
> level name 'level';
> end.
>
> In VBA, I did the following code:
>
>
> Public Declare Function dlevel Lib "CE" Alias "level" (ByVal x1 As
> Integer, ByVal x2 As Integer) As Integer
>
> Function nivel(ByVal x1 As Integer, ByVal x2 As Integer) As Integer
> nivel = dlevel(x1, x2)
> End Function
>
> In the sheet, I did:
>
> =nivel(2;5)
>
> And I got:
> #value
>
> I really don't know what to do. Seemlngly, VBA code is correct. I
> don't know so much about DLLs, would be possible to have a mistake in
> my Pascal code?
>
> Does someone have any idea?
>
> Best regards,
>
>
> --
> Luciano de Souza
>


-- 
Luciano de Souza



More information about the fpc-pascal mailing list