| || |
RegisterUserFunc on CreateObject("Excel.Application")?
I've done a lot with user-defined functions for web objects but we're driving a lot of our automation with data loaded from Excel files. Currently, all of my actions that pull that data from Excel files require me to cut and paste several functions that I wrote into the script. I'm wondering if it's possible to register a user-defined function for a CreateObject type? I'd like to be able to create an external function library with Excel function calls, include the RegisterUserFunc calls in that file and then associate the function library to a script. Doing so would allow easier implementation by my team should they wish to include the functionality.
I'm looking for some way to allow my team to call these methods like this:
objExcel.ReadCell [row], [col]
objExcel.WriteCell [row], [col], [value]
Any thoughts on the possibility of being able to do this in QTP/UFT?
How about using class construct .. like sample below. You can achieve what you are looking for by this way
Property set Prop(obj)
Set oExcel1 = obj'CreateObject("Excel.Application")
Set objExcel = new SampleClass
Set objExcel.Prop = CreateObject("Excel.Application")
I've never worked with custom class declarations. I'm going to try this first thing in the morning when I get back into the office! Thank you so much for pointing me in that direction!
Originally Posted by Prashin2QTP
A class is exactly how I have done this. I've been using it for 3 or 4 years now, making changes as needed. If you have any questions about how I've done it, I'll be glad to help.