There has been a few posts concerning the process of calling a Baan DLL function from VB code within a Windows application.
The attached zip file contains an example Excel spreadsheet and DLL that extracts Baan Text.
Baan DLL Function: (Library tudllolegwc)
VB Code:
Sub GetBaanText()
Dim BaanCompany As Long
Dim TextNumber As Long
Dim Line As Long
Dim StrText As String
BaanCompany = Val(Cells(2, 1)) ' cell (row 2, col 1) is Company
TextNumber = Val(Cells(2, 2)) ' cell (row 2, col 2) is Text Number
Line = 1
Cells(2, 3) = ""
Call GetTextLines(BaanCompany, TextNumber, Line, StrText)
Cells(2, 3) = StrText ' cell (row 2, col 3) is returned Baan Text
End Sub
Sub GetTextLines(compnr As Long, TxtNum As Long, ByRef Line As Long, ByRef Text)
Dim LineCnt As String
Dim rText As String
Dim strTxtNum As String
Dim strCompany As String
Dim strLine As String
strCompany = Format(compnr, "000")
strTxtNum = Format(TxtNum, "000000000")
strLine = Format(Line, "0000")
cText = ""
' Loop until all lines of text are returned (4K bytes returned with each call)
While Line > 0
rText = String(4000, " ")
dllname = "otudllolegwc"
dllfunction = "tudll.olegwc.get.text.blks" & "("
dllfunction = dllfunction & Chr(34) & strCompany & Chr(34) & ", "
dllfunction = dllfunction & Chr(34) & strTxtNum & Chr(34) & ", "
dllfunction = dllfunction & Chr(34) & strLine & Chr(34) & ", "
dllfunction = dllfunction & Chr(34) & rText & Chr(34) & ")"
Call SendtoBAAN(dllname, dllfunction)
' Baan4
strlen = Len(BaanObj.FunctionCall)
tstr = BaanObj.FunctionCall
' Baan5
'strlen = Len(BaanObj.ReturnCall)
'tstr = BaanObj.ReturnCall
Line = Val(Mid(tstr, 47, 10))
tstr = RTrim(Mid(tstr, 53, strlen - 4))
cText = cText & RTrim(Mid(tstr, 1, Len(tstr) - 2))
Wend
Text = cText
End