Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
srp_com vs oi_com
We want to use srp_com with the word.application object and found out it doesn't work properly.
Latest version of srp utility on OI 9.4 office tested at 2010 and 365
Below example with both wrappers.
As far as we can see SRP can’t get an object from an object.
“Release” also does nothing.
Maybe we are doing something wrong?
*Example OI com wrapper
wordapp = Olecreateinstance("Word.Application")
Oleputproperty(wordapp,'visible',1)
name = Olegetproperty(wordapp,'Name')
documents = Olegetproperty(wordapp,'Documents')
document = Olecallmethod(documents,'Add')
count = Olegetproperty(documents,'Count')
call msg('','OI Com wrapper||':name:'||':count*1:' Documents')
res = Olecallmethod(wordapp,'Quit')
clear
* Example srp_com wrapper
declare function srp_com
res = srp_com(wordapp,'CREATE','Word.Application')
res = srp_com(wordapp,'Set','Visible',1)
name = srp_com(wordapp,'Get','Name')
documents = srp_com(wordapp,'Get','Documents')
document = srp_com(documents,'Call','Add')
count = srp_com(documents,'Get','Count')
call msg('','SRP Com wrapper||':name:'||':count*1:' Documents')
res = SRP_Com(wordapp,'Call' 'Quit')
res = SRP_Com(documents, "RELEASE")
res = SRP_Com(document, "RELEASE")
res = SRP_Com(wordapp, "RELEASE")
return
Latest version of srp utility on OI 9.4 office tested at 2010 and 365
Below example with both wrappers.
As far as we can see SRP can’t get an object from an object.
“Release” also does nothing.
Maybe we are doing something wrong?
*Example OI com wrapper
wordapp = Olecreateinstance("Word.Application")
Oleputproperty(wordapp,'visible',1)
name = Olegetproperty(wordapp,'Name')
documents = Olegetproperty(wordapp,'Documents')
document = Olecallmethod(documents,'Add')
count = Olegetproperty(documents,'Count')
call msg('','OI Com wrapper||':name:'||':count*1:' Documents')
res = Olecallmethod(wordapp,'Quit')
clear
* Example srp_com wrapper
declare function srp_com
res = srp_com(wordapp,'CREATE','Word.Application')
res = srp_com(wordapp,'Set','Visible',1)
name = srp_com(wordapp,'Get','Name')
documents = srp_com(wordapp,'Get','Documents')
document = srp_com(documents,'Call','Add')
count = srp_com(documents,'Get','Count')
call msg('','SRP Com wrapper||':name:'||':count*1:' Documents')
res = SRP_Com(wordapp,'Call' 'Quit')
res = SRP_Com(documents, "RELEASE")
res = SRP_Com(document, "RELEASE")
res = SRP_Com(wordapp, "RELEASE")
return
Comments
Make sure you put a comma before 'Quit' if you actually want Word to close. Also, RELEASE is working even though it doesn't change the handles to 0.
Argh, we have 2.0.2 RC2 since last week but i was testing in the wrong installation.
If I test this on 2.0.2 RC2 , I get SRP_COM line 139 Non numeric when numeric required, Zero used.
On our line document = srp_com(documents,'Call','Add').
When I change parameters and test a couple of more times it suddenly works. After restarting OI it lands in the debugger again.
Regards Ed