Ruskin
10th June 2002, 05:01
There has been some discussion on using OLE to activate a Baan object and call a Baan DLL. I have also had some questions, on activating Baan sessions and objects, via Visual Basic where OLE is not suitable. As a result, I have decided to post a couple of text files, that people may find useful. I must stress, that this may NOT be the best way to activate your Baan object and I am not attempting to tell you not to use OLE (which has advantages over this method), but there are some cases, where this code is more useful. A common instance, where you would want to use this method, is if you do not have the appropriate BWC file registered on each computer, thus using OLE will not work when you try to use the 'CreateObject' VB function.
eg: CreateObject("Baan4.Application.B4_Config")
Will only work if the B4_Config BWC file is correctly registered on the client PC. However, this is not always the case, thus activating the B4_Config BWC file, must be performed via a different method, other than OLE. You could still use OLE to activate the B4_Config BWC file, but you would have to do;
CreateObject("Baan4.Application")
Then hope like hell, that your user selects the correct config file (bit dangerous for some users).

The method I have used, is to activate the BW executable, with a configuration file. The configuration file, then activates a 3GL Baan programme (in the command setting) passing parameters, which are then read by the argv$() Baan function. The example files allow you to use a VB front end to manipulate activities attached to a project and call the BWC file to rebuild the activities, for the given project.

The vb_tip.txt file contains the VB code used to activate the BWC file. NOTE: this code automatically determines where BW.EXE is installed (on the local PC) and will activate the BWC file and stay in a loop until the programme is shut down. This is called by;
RunBaanDLL(<3 GL Programme>, <BWC File>, <Parameters For DLL>)
eg:
RunBaanDLL("otccomprog", "B4_CONFIG.BWC", "parm1 parm2 parm3")

The vb_tip.txt file, also contains the Baan code for the 3GL programme, to read the passed parameters and perform whatever Baan functions are needed, such as activating another DLL, or running queries/updates, etc.

Hope this is of some help...

mark_h
10th June 2002, 16:33
Interesting concept and could be very helpful to others. This is the type of thing we are looking for in the Code and Utilities Forum. If you get some time maybe you could post it in that forum also.

Thanks

Mark

Ruskin
10th June 2002, 23:52
Thanks Mark,

I was wondering where I should post this and was not aware of the Code and Utilities forum. Sounds like a much better place for this posting.

regards,
Ruskin...

Ruskin
11th June 2002, 00:18
Tip:

The code, in this utility, indicates a sequential read of the BWC file to write the records to a temporary BWC file and then overwrite the original (ie: if the original BWC is CONFIG.BWC, this code writes the records to TEMP.BWC, with the new 'command' setting, then overwrites CONFIG.BWC with TEMP.BWC). This is not necessarily the best way to achieve this. The BWC file is maintained in the same way INI files are, with;
[Application]
Key=Value
As a result, the following lines could be used in place of the 'RebuildConfigFile' function;

in the General Declarations section;
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

replacing the 'RebuildConfigFile' function call with;
x = WritePrivateProfileString("ApplicationServer", "command", Trim(rbDLLName) & " " & rbParameters, rbConfigFile)

I have added this post to the Code and Utilities forum as well..

monica23
14th December 2007, 16:13
hi when i try to connect vb its give error Activex control can't create object...anybody can help me