View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default ATPVBAEN.xla!Moveavg- where to find explanation of arg involved.

Hi Joel,

The OP is asking how to use functions in the ATPVBAEN.xla. This addin is a
glorified wrapper to call functions in ANALYS32.XLL. Normally for VBA to
call functions in an XLL means using Application.Run (after Registering the
functions). In theory, even though documented otherwise, it should be
possible to call functions directly from an XLL without app.run. However I
have not managed to do that from the ATP xll, possibly due to
incomplete/incorrect use of LPXLOPER __stdcall. Do you know how to write the
declarations?

Regards,
Peter T

"Joel" wrote in message
...
You can use any DLL in a VBA macro by defining the call to the library
function, Here is an example

' Declare wininet.dll API Functions
Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias
"FtpSetCurrentDirectoryA" _
(ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean

Public Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias
"FtpGetCurrentDirectoryA" _
(ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String,
lpdwCurrentDirectory As Long) As Boolean

Public Declare Function InternetWriteFile Lib "wininet.dll" _
(ByVal hFile As Long, ByRef sBuffer As Byte, ByVal lNumBytesToWite As
Long, _
dwNumberOfBytesWritten As Long) As Integer

Public Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA"
_
(ByVal hFtpSession As Long, ByVal sBuff As String, ByVal Access As Long,
ByVal Flags As Long, ByVal Context As Long) As Long

Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
ByVal lpszRemoteFile As String, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean



Usually I go to microsfot.com and find the paraemeter list and entry
points
for the library function. There is some manpulating of the parameter
definitions that you have to do. For example parameters which are
pointers
are defined in VBA as Long. Then you have to define a TYPE (in place of a
structure in C language) in VBA like this

Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As Currency
ftLastAccessTime As Currency
ftLastWriteTime As Currency
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

This type is used below

Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias
"FtpFindFirstFileA" _
(ByVal hInternetSession As Long, ByVal lpszSearchFile As String, _
ByRef lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, _
ByVal dwContext As Long) As Long



"Vivadad" wrote:

For ATP and similar add-in, I always confused where I can get details how
to
use their inbuilt functions. Also, any library souce for me to know what
function i can pick out to use form which "possible add-in" (including
xla,
dll etc.)
thanks,