Micro Focus QTP (UFT) Forums
To Get number of menu items of a winmenu object - 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: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: To Get number of menu items of a winmenu object (/Thread-To-Get-number-of-menu-items-of-a-winmenu-object)



To Get number of menu items of a winmenu object - sasmitakumari - 07-08-2010

Here is how I have calculated number menu items and label of a menu item of a winmenu object in QTP.

Code:
For i = 1 to n  'n value should be given with expected number of menu items +1
   boolExists = winMenuObj.GetItemProperty("<Item "&CStr(i)&">", "Exists")
   If boolExists = False Then
    Exit For
    Else
        itemIndex = winMenuObj.GetItemProperty("<Item "&CStr(i)&">", "Index")
    itemLabel = winMenuObj.GetItemProperty("<Item "&CStr(i)&">", "Label")
   End If
Next

'itemIndex gives total number of items exists in the winmenu object when it comes out from the For loop
Smile