Micro Focus QTP (UFT) Forums
Object required on SetToProperty - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Object required on SetToProperty (/Thread-Object-required-on-SetToProperty)



Object required on SetToProperty - zerocool - 12-01-2010

I'm trying to write a script using QTP but got stuck on SetToProperty method.I need to change date in and object innerhtml. After I do that then when I try to set the value Using SetToProperty I'm having error Object required:
For reference here is my code.

Code:
Browser("MyPurolator Login - Purolator").Page("MyPurolator Home - Purolator").Link("Create a Shipment").Click

Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").Sync

Set var_date = Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebTable("WebTable")

var_date = var_date.GetTOProperty("innerhtml")

MsgBox var_date

var_date = replace(var_date, "2010-12-11 ", "2010-12-02 ")

MsgBox var_date

DataTable.Value("value", dtGlobalSheet) = var_date

var_temp = DataTable.Value("value", dtGlobalSheet)

MsgBox var_temp

var_date.SetTOProperty "innerhtml", var_temp (THIS IS WHERE HAVING ERROR)

' Set value of web table then sync

MsgBox var_date.GetTOProperty("innerhtml")

Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").Sync

Can somebody help me to resolve it?

Many Thanks in Advance.


RE: Object required on SetToProperty - cdesserich - 12-02-2010

In the line:

Code:
var_date = var_date.GetTOProperty("innerhtml")

you are overwriting the variable that used to hold the object. Create a new variable to hold the original innerhtml of the test object.

Code:
Browser("MyPurolator Login - Purolator").Page("MyPurolator Home - Purolator").Link("Create a Shipment").Click

Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").Sync

Set var_date = Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebTable("WebTable")

var_innerhtml = var_date.GetTOProperty("innerhtml")

MsgBox var_innerhtml

var_innerhtml = replace(var_date, "2010-12-11 ", "2010-12-02 ")

MsgBox var_innerhtml

var_date.SetTOProperty "innerhtml", var_innerhtml

MsgBox var_date.GetTOProperty("innerhtml")