I've tried to implement the simple example shown in the Calc Help system for
the Declare Statement. Somewhere it expects to find a file: user32.dll but
I have no idea where to find it. Windows has many user32.dll files for
it's own use but presumably none of them are relevant to LibreOffice.The
file does not seem to be included in the DLL files that install with Libre.
So does it need to be downloaded from the web somewhere and manually
installed?I'm just trying to understand how to link Basic to a DLL file so I
can go off and do something more complex. Thanks.Bill
The point is that the user32.dll file is not relevant to LibreOffice, yet you should be able to call methods in it.
What is your operating system? Obviously it is Windows, so, which version of windows? 7, 8?
What error do you receive if you try to run the following macro?
Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( Long )
Declare Function CharUpper Lib "user32.dll" Alias "CharUpperA"_
(ByVal lpsz As String) As String
Sub ExampleCallDLL
REM Convert a string to uppercase
Dim strIn As String
Dim strOut As String
strIn = "i Have Upper and Lower"
strOut = CharUpper(strIn)
MsgBox "Converted:" & CHR$(10) & strIn & CHR$(10) &_
"To:" & CHR$(10) & strOut, 0, "Call a DLL Function"
REM On my computer, this plays a system sound
Dim nBeepLen As Long
nBeepLen = 5000
MyMessageBeep(nBeepLen)
FreeLibrary("user32.dll" )
End Sub
Win XP is on the particular old machine I'm using. No error message, just
doesn't seem to work properly. Just an error beep, not a tone of specified
duration. Since Win XP is scattered full of files named user32.dll, I
presume Libre was just picking up the wrong one.
Once I gave up on the example though, I went back to my own DLL code and
Basic program. I finally got it to work if I put my DLL in the Libre "bin"
subdirectory. Libre wouldn't find it when I placed the DLL in with my ODS
files as Excel would have.
Apparently I need to somehow tweak the Libre settings to make it look for
the DLL in the same subdirectory as my spreadsheet files. Providing a fully
specified path name for the DLL in the Declare statement wasn't the answer.
Thanks.
Bill