Can someone please help me figure out a problem using HLLAPI function calls. This should be easy but my solution hasn’t worked yet. I have several Excel 2000 files that pass information with VBA to Extra 6.7 using HLLAPI function calls ... now I need a field of data to pass the other way too ... from Extra to Excel.
My current process requires the user to manually intervene at certain points to get information from the Extra screen, place it into Excel and then continue running the VBA. I want to remove this manual portion of the work by having the VBA code pull the field from the screen. The information is always 3 characters long and always in the same screen position.
I prefer to handle this routine using HLLAPI function calls since all the other interaction between Extra and Excel is through HLLAPI. All the timing issues have already been addressed with HLLAPI … so I don’t want to change to VBA screen scraping since timing problems are likely to pop up again.
The HLLAPI documentation reads as though this should be an easy task. Function 8 and/or 34 should accomplish this. I’ve used function 8 many times when I wanted to get a string and compare it to another string using function 6. Using these functions together works great when I am searching for a known string.
In this case, the three-character field could be anything. I simply want to use the HLLAPI function to return the string into a variable so I can place it into the spreadsheet. This isn’t working for me. Hopefully, I’ve just made a dumb mistake that someone can point out.
To simply my problem, I prepared the following sample VBA code:
Private Func As Integer, Astr As String, Alen As Integer, RetC As Integer
Private Declare Function HLLAPI Lib "C:\Program Files\EXTRA!\EHLAPI32.DLL" (Func%, ByVal Buffer$, bSize%, RetC%) As Long
'create the HLLAPI function, call the proper DLL file, display the returned value is a message box
Private Function HLL(Func, Astr, Alen, RetC)
HLLAPI Func, Astr, Alen, RetC
MsgBox ("astr = " & Astr & " alen = " & Alen & " retc = " & RetC)
End Function
'copy screen location row 2 column 4 (position 84) to string (3 characters only)
Sub TestCopy()
'connect to presentation space (ps)
Call HLL(1, "A", 0, 1)
'set function 8 copy ps to string, allocate empty space to hold string, set length, set screen position
Call HLL(8, " ", 3, 84)
End Sub
The returned values work okay for the Length and the Return Code; however, the Data String that I need does not return. When I use API trace, the proper values are reported; however, they don’t make it back through my code.
Below are the results of an API trace:
CONNECT (Function 1)
Entry: Length 0 PS Position 1
1DA7:0000 : 41 . A
Exit : Length 0 Return 0
COPY PRESENTATION SPACE TO STRING (Function 8)
Entry: Length 3 PS Position 84
Exit : Length 3 Return 0
1DA7:0000 : 46 57 44 . FWD
Notice that function 8 returned the string “FWD” for this example. Unfortunately, the string was not passed to the variable in the MsgBox; however, the Length and the Return Code were passed okay.
I have also tried function 34 with the same results. Any comments and/or suggestions are welcome and appreciated. Thanks in advance.
My current process requires the user to manually intervene at certain points to get information from the Extra screen, place it into Excel and then continue running the VBA. I want to remove this manual portion of the work by having the VBA code pull the field from the screen. The information is always 3 characters long and always in the same screen position.
I prefer to handle this routine using HLLAPI function calls since all the other interaction between Extra and Excel is through HLLAPI. All the timing issues have already been addressed with HLLAPI … so I don’t want to change to VBA screen scraping since timing problems are likely to pop up again.
The HLLAPI documentation reads as though this should be an easy task. Function 8 and/or 34 should accomplish this. I’ve used function 8 many times when I wanted to get a string and compare it to another string using function 6. Using these functions together works great when I am searching for a known string.
In this case, the three-character field could be anything. I simply want to use the HLLAPI function to return the string into a variable so I can place it into the spreadsheet. This isn’t working for me. Hopefully, I’ve just made a dumb mistake that someone can point out.
To simply my problem, I prepared the following sample VBA code:
Private Func As Integer, Astr As String, Alen As Integer, RetC As Integer
Private Declare Function HLLAPI Lib "C:\Program Files\EXTRA!\EHLAPI32.DLL" (Func%, ByVal Buffer$, bSize%, RetC%) As Long
'create the HLLAPI function, call the proper DLL file, display the returned value is a message box
Private Function HLL(Func, Astr, Alen, RetC)
HLLAPI Func, Astr, Alen, RetC
MsgBox ("astr = " & Astr & " alen = " & Alen & " retc = " & RetC)
End Function
'copy screen location row 2 column 4 (position 84) to string (3 characters only)
Sub TestCopy()
'connect to presentation space (ps)
Call HLL(1, "A", 0, 1)
'set function 8 copy ps to string, allocate empty space to hold string, set length, set screen position
Call HLL(8, " ", 3, 84)
End Sub
The returned values work okay for the Length and the Return Code; however, the Data String that I need does not return. When I use API trace, the proper values are reported; however, they don’t make it back through my code.
Below are the results of an API trace:
CONNECT (Function 1)
Entry: Length 0 PS Position 1
1DA7:0000 : 41 . A
Exit : Length 0 Return 0
COPY PRESENTATION SPACE TO STRING (Function 8)
Entry: Length 3 PS Position 84
Exit : Length 3 Return 0
1DA7:0000 : 46 57 44 . FWD
Notice that function 8 returned the string “FWD” for this example. Unfortunately, the string was not passed to the variable in the MsgBox; however, the Length and the Return Code were passed okay.
I have also tried function 34 with the same results. Any comments and/or suggestions are welcome and appreciated. Thanks in advance.