API (HLLAPI) errors when accessed from VBA.

Hi, thanks for taking a look at this.

I use VBA often to create macros that screen-scrape from a 3270 emulator. (Attachmate Extra 6.7 if important.)

I am trying to access the HLLAPI (from Attachmate) from Excel. I am declaring as follows:

Public Declare Sub WinHLLAPI Lib "WHLAPI32.dll" (Func%, ByVal HllDataStr$, HllDataLgth%, PsPos%)

Public Declare Function WinHLLAPIStartup Lib "WHLAPI32.dll" (ByVal version%, ByVal Buffer$) As Long

Public Declare Function WinHLLAPICleanup Lib "WHLAPI32.dll" () As Long

Then the first time I call I am using:

WinHLLAPIStartup 257, Space(100)

I get a runtime error, #53 - file not found. The file is there and the calls are accurate, including case. I can access the API when coding in the proprietary basic language supported by the emulator using the equivalent declarations and calls shown above.

I have tried the following to troubleshoot:

  • Declaring all functions as privates. (Should not make a difference)
  • Declaring winHLLAPI as a function. (Both should work)
  • Bypassing the startup call and calling a function by number in WHLAPI32.dll.
  • Using the various HLLAPI's from attachmate.
  • Providing a complete path to the .dll in the declare (ie: C:\Program Files\Extra67\win2k\eng\WHLAPI32.dll) (My system path)

The API is designed to be fully functional in a VB environment and should be fine in VBA, as all the others seem to have been. I suggest I am doing something incorrect in the declarations, but cannot seem to diagnose.

Any thoughts / assistance would be appreciated.


Answer this question

API (HLLAPI) errors when accessed from VBA.

  • Sanchit Bahal

    Hi,

    If you provided the full path to the DLL is funny your getting a file not found error. Unless it's another file that the DLL itself requires thats missing. Have you tried to walk the dependencies of the DLL and see if there is another file required by the DLL that's missing



  • API (HLLAPI) errors when accessed from VBA.