MACRO4 calls DLL, how do I do this in VBA?

User avatar
ErikJan
BronzeLounger
Posts: 1254
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

MACRO4 calls DLL, how do I do this in VBA?

Post by ErikJan »

I have Excel4 Macro code which looks like this:

REGISTER( "DLL Path & Name","xxx","RRRRRRRRRRR","xxx","function,server,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8",2,"User Defined")

I added the "xxx" myself to mask the call name but the "RRRR..." string was there like it is. How do I set up this call in VBA?

I have an old HELP file and see this is the syntax:

REGISTER(module_text, procedure, type_text, function_text, argument_text, macro_type, category, shortcut_text, help_topic, function_help, argument_help1, argument_help2,...)

As this is "type_text" I checked the help... it says:
Type_text is text specifying the data type of the return value and the data types of all arguments to the DLL or code resource. The first letter of type_text specifies the return value. The codes you use for type_text are described in "Using the CALL and REGISTER Functions" in the Appendix for the Worksheet Function Reference, or Using the CALL and REGISTER Functions in online Help.For stand-alone DLLs or code resources (XLLs), you can omit this argument.
"Using the CALL and REGISTER Functions" is a link, however I cannot get this help section in my HELP file...

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MACRO4 calls DLL, how do I do this in VBA?

Post by HansV »

See Jan Karel Pieterse's series of articles Register UDFs.
Excel 2010 finally introduces a way to do this in VBA; in earlier versions you have to use Excel 4 macros.
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1254
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: MACRO4 calls DLL, how do I do this in VBA?

Post by ErikJan »

OK, I'll read but even though it says "User Defined" I don't think it is actually intended to be used in Excel as a function. All I need is to call it in VBA (and, regretfully, @ work we still have 2007...)

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MACRO4 calls DLL, how do I do this in VBA?

Post by HansV »

if you want to use a DLL function in VBA, you can use the Declare keyword. See for example Anatomy of a Declare statement (it's for XP but applies to 2003 and 2007 as well).
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1254
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: MACRO4 calls DLL, how do I do this in VBA?

Post by ErikJan »

OK, but I still don't see what the "RRRRRRRRRRRRR" means...

Also, what is returned? Here's the call again but I made it more complete

=FORMULA( REGISTER( "my dll","xxx","RRRRRRRRRRR","xxx","function,server,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8",2,"User Defined"), fxxx)

Here "fxxx" refers to a number which looks like 1185913448 (but is different)

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MACRO4 calls DLL, how do I do this in VBA?

Post by HansV »

I don't have the slightest idea, sorry.
Best wishes,
Hans

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: MACRO4 calls DLL, how do I do this in VBA?

Post by macropod »

ErikJan wrote:OK, but I still don't see what the "RRRRRRRRRRRRR" means...

Also, what is returned?
Both of those are determined by your dll. Since we have no idea what your dll is or does, we'd only be guessing.
Paul Edstein
[Fmr MS MVP - Word]