james.niddrie
4th September 2023, 15:44
Hi,

I'm wanting to execute Baan sessions from a VB.NET project built in Visual Studio 2022. I've been given the Excel workbook example which seems to work OK but I'm getting errors when I move the code to VB.NET.

The issue I'm finding is that the methods and properties are not being recognized. When I look at the dynamic properties during code execution I don't see the ParseExecFunction method for example. I'm also getting a "Public member 'Timeout' on type 'IAutomateBaan4' not found." when executing BaanObj.Timeout = 1000 even though I can "see" Timeout as as a dynamic property.

Thanks

James

Can anyone help point me in the right direction with a working example or any suggestions on how I can get the code working in "full fat" VB.

mark_h
4th September 2023, 18:15
Do you have the baan windows client installed? One of the tabs is automation - the class name is what you should use in your create object. So for example on my BWC I have the class name Baan4.Application.101 in the automate tab. So then in my excel spreadsheet example I would do a set BaanObj = CreateObject ("Baan4.Application.101") - then typically after that I set BaanObj.Time =10 (or whatever number you want). I only played with this a few times and found the connection (at least in our company) to be too slow for the customers (in my opinion). We never really used it and now I do not have the access to even test it - just some old spreadsheets I kept with the old macros.

james.niddrie
5th September 2023, 12:22
Hi Mark,

Thanks for your reply. I was doing some more research last night and I found the issue.

Using vb.net you can create the Baan instance the same way as in VBS in Excel i.e.

Dim BaanObj as Object

Creating it this way uses what's called late binding (runtime) to identify the methods and properties. This should work as in VBS but doesn't in full fat VB.

The solution is to go for early binding but for this you need to define the methods and properties before compilation. To do this you need to add a reference to the the COM object. This is done in visual studio (should be plenty of links on the web on how to do that) by browsing for the file (in my case) C:\Program Files (x86)\Infor\BW\Baan IV\bin\bw.tlb

Once the reference is added then Visual Studio knows about all the methods and properties. The final thing you need to do is to define the initial Baan connection differently....

Dim BaanObj As Baan4.IDispatchBaan4

Once you have this the rest of the code in the Excel samples works perfectly.

mark_h
11th September 2023, 01:31
I am glad you found the solution. Maybe someone else knows all of that - but that is beyond my skill set. All I did was play with excel examples and get them working.