Getting item description through Baan OLE automation
I have little or no experience related to Baan OLE automation, but i want to explore it. I want to perform a simple task as shown below:
pass an item code using stpapi.put.field
search the item record using stpapi.find
get the value of item description using stpapi.get.field
For this I have written attached code in Excel VBA. I have debugged code in VBA and it gives an error message indicating invalid number of arguments whereas I am passing three argument (sessioncode,tablefield,getfield) to stpapi.get.field function.
getfield is excel vba variable.
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & "tiitm001.dsca" & Chr(34) & "," & getfield & ")"
Can anybody guide me how to write the above statement correctly in VBA so that I will get item description in getfield variable ?
I could get rid of the error with below statement:
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & "tiitm001.dsca" & Chr(34) & ",itemdesc" & ")"
But still while displaying value of itemdesc, the value remains empty.
Any clue what could be wrong here ?
NOTE : I changed the name of variable from getfield to itemdesc
I only have this that I tested a couple of times - notice the baan function call and how I had to use mid$ to get a description.
Your code is working. One strange thing (and it has nothing to do with your code) is if I am already connected to Baan and run my macro then I get ole automation error. For the code to work, I have to logout of Baan, then only I can run the Excel code.
Thanks for your help.
Yes - I recall that happening also. I believe that was one of the reasons I never went this direction because it was very slow in our environment. I never really played with this a lot.
|All times are GMT +2. The time now is 21:58.|
©2001-2017 - Baanboard.com - Baanforums.com