Micro Focus QTP (UFT) Forums
Error while creating object using description.create object in VB script - 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: Error while creating object using description.create object in VB script (/Thread-Error-while-creating-object-using-description-create-object-in-VB-script)



Error while creating object using description.create object in VB script - SarodeGirish - 06-19-2012

Code:
Dim objVar
set objVar=description.create

After executing this code its showing the error.

Object required description


RE: Error while creating object using description.create object in VB script - ssvali - 06-19-2012

I am not getting any error.

Can you brief out exactly what are you trying to do ?


RE: Error while creating object using description.create object in VB script - SarodeGirish - 06-19-2012

'Create a description for browser

Code:
Set oBrowser = Description.Create
oBrowser("micclass").Value = "Browser"

'Get all browsers
Set allBrowser = Desktop.ChildObjects(oBrowser)

Dim i, iCount

iCount = allBrowser.Count - 1

For i = 0 To iCount
    
allBrowser(i).Close
  
Next




After executing the above code I am getting the error as "Object required 'Description'


RE: Error while creating object using description.create object in VB script - ssvali - 06-19-2012

I tried ur code and it is perfectly working.

R u executing the below thru QTP or .vbs file ?


RE: Error while creating object using description.create object in VB script - SarodeGirish - 06-19-2012

I am not using QTP. I am using .vbs file.


RE: Error while creating object using description.create object in VB script - ssvali - 06-19-2012

I think Description.Create does not support in .vbs file as it belongs to QTP.

Try below code to close all browsers thru .vbs file

Code:
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery( "Select * from Win32_Process where name = 'iexplore.exe'")
For Each objProcess in colProcesses
objprocess.terminate
Next
Set colProcesses = Nothing
Set objWMIService = Nothing