Hi Gurus,
I have an asm program that retrieve data from other system and it 's working fine.
Now I want to make it as an "plug in for Excel" or "an Library" in order VBA code can reuse it ?
Any advise are welcome
m
Posted on 2003-09-04 21:20:32 by nvm
If you're into COM, you can make a COM Object for the asm program.

If you don't want that level of complexity you can make a DLL and make function calls from VBA. I don't have an example here at home, I'll look for one and post it later. Several things to watch out for when doing this: You must use stdcall calling convention, understand the way VBA passes parameters, and the DLL will have to reside either in the same directory as the Excel file or somewhere on the standard LoadLibrary search paths.
Posted on 2003-09-04 22:10:00 by Mecurius
VBA does not support asm code.(am I wrong?)
Posted on 2003-09-05 02:37:09 by etn

VBA does not support asm code.(am I wrong?)


Neither VB nor VBA support asm code :)
Anyway, both VB and VBA can link to functions exported by DLLs.

Just as Mercurius wrote:
You must use stdcall calling convention, understand the way VBA passes parameters,
and the DLL will have to reside either in the same directory as the Excel file or somewhere on
the standard LoadLibrary search paths.


To declare a function in VB(A):



Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA"
([b]ByVal[/b] HWND As Long, ByVal Message As String, ByVal Title As String, ByVal Flags As Long) As Long


ByVal is very important, as by default VB(A) pass parameters by reference (so you would get a pointer to a value instead of the value itself). Strings are double-referenced in VB(A), so "ByVal X As String" will pass a pointer to null terminated string, whilst "X As String" would pass a pointer to a pointer to a string.
Posted on 2003-09-05 07:37:24 by Morris
I have several examples if you'ld like (mostly passing numeric data & arrays) - let us know a little more specifics of your task and I'll see if I can help.
Posted on 2003-09-05 12:07:50 by TheoMcCloskey
Thank TheoMcCloskey I decided to make the dll file and let VBA call its export functions
Posted on 2003-09-10 23:34:14 by nvm