Micro Focus QTP (UFT) Forums
why error if available methods are used. - 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: why error if available methods are used. (/Thread-why-error-if-available-methods-are-used)



why error if available methods are used. - AAB - 06-13-2012

Hi,
Though a lot of code is available for working with excel still want to clear a confusion as follows:

Code:
Set obj=Createobject("Excel.application")
obj.visible=True

Now when i use the following code:
obj.worksheets.add or
obj.worksheets(1).add

It shows "Unknown runtime error"

Not able to understand why is it so.Can anybody clarify this?


RE: why error if available methods are used. - manabh - 06-13-2012

Hi,
Set obj=Createobject("Excel.application")
After this statement, check
Code:
If obj = nothing then
    read error!
end if



RE: why error if available methods are used. - ravi.gajul - 06-13-2012

Please correct your code
Code:
Set obj=Createobject("Excel.application")
obj.visible=True
Obj.WorkBooks.add




RE: why error if available methods are used. - AAB - 06-14-2012

Thanks for your reply.
Actually the confusion i had was why it showed error on placing worksheets in place of workbooks in the above code.
But now i have found that it shows error as it does not know in which workbook it should add the worksheet.