Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
How to get the menu items for lower level menu
posted

Good afternoon,

I have a menu which has child menus that I have already built a functio work with. I now need to go 1 more level deep. Below is the code for the function and the calling code. I need some help on line 183 which is the last code to get the 3rd level menu.

Menu / Item 1 works with existing funciton

Menu / Item 1 / SubItem 1 I cannot get past the error on line 183 see code below.

Regards,

Brian

Set objectMainPage = SwfWindow("Summit FT - Bond Definition")

'Process the selection of  Bond Definiton, Analytics, Details... from the menu
'Build up the menu code here to select from the menus
Set objectToolBar =objectMainPage.SwfToolbar("_toolbarsDockAreaTop")
specifiedToolBar = "Desktop Menu"
specfiiedToolBarMenuItem = "Bond Definition" 'This is what the text that you see is without the shortcut keybon
specifiedToolBarSubMenu = "Validate" 'Text is case sensitive
specifiedToolBarSubSubMenu = "Details..." 'Text is case sensitive
nameToolBar = "" 'Toolbar name
nameToolBarMenu = "" 'Toolbar main menu item
nameToolBarMenuSubMenu = "" 'The submenu name
nameToolBarMenuSubSubMenu = "" 'The submenu name
objectToolBarSubSubmenu = "" 'The object to recieve the subsubmenu object for validation of enabled etc properties in the calling script
reporterDetailsFuncSelectToolBar = ""
'Get the toolbar text/name with the toolbarbutton text/name
eventCodeFuncSelectToolBarMenu = CommonTMSSelectToolBarMenuItemTwoLevels(objectToolBar, specifiedToolBar, specfiiedToolBarMenuItem, specifiedToolBarSubMenu, specifiedToolBarSubSubMenu, nameToolBar, nameTBarItem, nameToolBarMenuSubMenu, nameToolBarMenuSubSubMenu, objectToolBarSubSubmenu, reporterDetailsFuncSelectToolBar)
If  eventCodeFuncSelectToolBarMenu = 0 Then
 'Click on the menu item by opening the dropdown and then selecting the submenu
 objectToolBar.DropdownToolbarTool specifiedToolBar,nameTBarItem
 'Click the submenu item right afterwards or it will not work ***No Steping Though This one
          'DropdownMenuTool "Desktop Menu,186:EntityView","197:Analytics"
 objectToolBar.DropdownMenuTool nameToolBar & "," &  nameTBarItem,  nameToolBarMenuSubMenu
 'Click the subsubmenu item right afterwards or it will not work ***No Steping Though This one
          'ClickMenuTool "Desktop Menu,186:EntityView,197:Analytics","208:Detail"
 objectToolBar.ClickMenuTool nameToolBar & "," &  nameTBarItem,  nameToolBarMenuSubSubMenu
 'Check if the tab for the main page has the Asset Details Tab
Else
 eventCode = 1
 eventLoopCode = 1
 reporterDetails = reporterDetails & reporterDetailsFuncSelectToolBar
End If

' @Function Name  CommonTMSSelectToolBarMenuItemTwoLevels
' @Description  Select the submenu item from the menu item. We are matching based on the text displayed for the menu item not the recorded values
' *******NOTE: you will need to get the toolbar name by recording the selection of a buttom and getting the toolbar name
' *****************Example
' SwfWindow("Summit FT - Calendar Definition").SwfToolbar("_toolbarsDockAreaTop").DropdownToolbarTool "Desktop Menu","57:EntityView"
                                             'DropdownMenuTool "Desktop Menu,186:EntityView","197:Analytics"
                                             'ClickMenuTool "Desktop Menu,186:EntityView,197:Analytics","208:Detail"
' Toolbar =  "Desktop Menu"
'ToolbarMenu= "EntityView"   ++++++++++++ We have replaced the compare based on the visible text to the user instead of the Key which is EntityView
' ToolbarSubMenu = "Open"

'********************Menu Submenu Selection
' Example if nameTBarMenu = "File" &  nameTBarSubMenu "Open" we will open the dropdown Menu for File and then select the submenu Open item
' @Documentation <objectPageToolBar> the toolbar control in the object repository for the page
' @Documentation <nameSpecifiedToolBar> the name of the toolbar to find
' @Documentation <nameSpecifiedToolBarButton> the name of the toolbar button to find
' Returns:
'  <nameTBar> the toolbar text/name for selecting the button
'  <nameTBarItem> the toolbar button text/name for selecting the button
'  <objectTBarSubMenu> the menu object found for use in the calling script to check enabled and other status.
'  <resultDetails> the details regarding the function
'  <resultCode> the result code for pass or fail
'  Otherwise, the value of the NoData environment valueJim
' Created: 04/25/2011 BLW
' Last Updated:
Function  CommonTMSSelectToolBarMenuItemTwoLevels(byVal objectPageToolBar, byVal nameSpecifiedToolBar, byRef nameSpecifiedToolBarMenu, ByRef nameSpecifiedToolBarSubMenu, ByRef nameSpecifiedToolBarSubSubMenu, byRef nameTBar, byRef nameTBarMenu, byRef nameTBarSubMenu, byRef nameTBarSubSubMenu, ByRef objectTBarSubSubMenu, byRef resultDetails)
' &&&&&&&&&&&& Note the values in the menu and compares are text and Case Senseitive. please insure you send in the value to match the menu item
 resultCode = 2
 countToolBar = 0
 booleanToolBarFound = False
 booleanToolBarMenuFound = False
 booleanToolBarSubMenuFound = False
 booleanToolBarSubSubMenuFound = False
 objectTBarManager = "" 'Temp destroy on exit
 objectTBar = "" 'Temp destroy on exit
 'Set the toolbar manager based on the control from the page
 Set objectTBarManager = objectPageToolBar.Object.ToolbarsManager.Toolbars
 countToolBar = objectTBarManager.Count
 If  countToolBar > 0Then
  For loopToolbars = 0 to countToolBar - 1
   nameTBar = Trim(objectTBarManager.GetItem(loopToolbars).Key)
   If nameTBar =  nameSpecifiedToolBar Then
    Set objectTBar =  objectTBarManager.GetItem(loopToolbars)
    booleanToolBarFound = True
    Exit For
   End If
  Next
  If booleanToolBarFound = False Then
   resultCode = 1
   resultDetails = resultDetails & " WE DID NOT FIND toolbar of: " & nameSpecifiedToolBar & " WE CANNOT SEARCH FOR THE MENU."
  End If
 Else
  resultCode = 1
  resultDetails = resultDetails & " WE DID NOT FIND ANY TOOLBARS."
 End If
 'Start looking for the menu if the assigned toolbar was found
 If booleanToolBarFound = True Then
  'See if we can get the menu next
  countToolBarMenus = objectTBar.Tools.Count
  If  countToolBarMenus > 0 Then
   'Check the button and see if we can find the one we specified
   For loopMenus = 0 to countToolBarMenus -1
    inStringToolName= ""
    textTBarItem = ""
    nameTBarMenu = objectTBar.Tools.GetItem(loopMenus).Key
    textTBarMenu = CStr(objectTBar.Tools.GetItem(loopMenus).CaptionResolved)
    stringHotKey ="&"
    'Strip out the & key for the hotkey in the menu item
    instringLoc = InStr(1, textTBarMenu, stringHotKey)
    lenString = Len(textTBarMenu)
    tempStringLeft = ""
    tempStringRight = ""
    Select Case instringLoc
     Case 0
      'Do nothing there is no hotkey specified for this item
     Case 1
      'Remove the & from the front of the text
      textTBarMenu = Right(textTBarMenu, lenString - instringLoc)
     Case Else
      'Build the string by gettting what is left of the & and then what is right of the &
      tempStringLeft = Left(textTBarMenu,instringLoc - 1)
      tempStringRight = Right(textTBarMenu, lenString - instringLoc)
      textTBarMenu = tempStringLeft & tempStringRight
    End Select
    'Check if the displayed text matches the requrested menu item
    If  textTBarMenu = nameSpecifiedToolBarMenu Then
     booleanToolBarMenuFound = True
     Set objectTBarMenu = objectTBar.Tools.GetItem(loopMenus)
     Exit For
    End If
   Next
   If  booleanToolBarMenuFound = False Then
    resultCode = 1
    resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " BUTthe menu item of: " & nameSpecifiedToolBarMenu & " was not found."
   End If
  Else
   resultCode = 1
   resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " BUT NO MENUS WERE FOUND."
  End If
 End If 'Tool Bar found and looking for the menu
 'Start Looking for the submenu item if menu found
 If booleanToolBarMenuFound = True Then
  'See if the menu item has any submenu items
  countToolBarSubMenus = objectTBarMenu.Tools.Count
  If  countToolBarSubMenus > 0 Then
   'Check the button and see if we can find the one we specified
   For loopSubMenus = 0 to countToolBarSubMenus -1
    nameTBarSubMenu = objectTBarMenu.Tools.GetItem(loopSubMenus).Key
    textTBarSubMenu = CStr(objectTBarMenu.Tools.GetItem(loopSubMenus).CaptionResolved)
    stringHotKey ="&"
    'Strip out the & key for the hotkey in the menu item
    instringLoc = InStr(1, textTBarSubMenu, stringHotKey)
    lenString = Len(textTBarSubMenu)
    tempStringLeft = ""
    tempStringRight = ""
    'Use case statement here to work with 0, 1, or else
    Select Case instringLoc
     Case 0
       'Do nothing there is no hotkey
     Case 1
      'Remove the & from the front of the text
      textTBarSubMenu = Right(textTBarSubMenu, lenString - instringLoc)
     Case Else
      'Build the string by gettting what is left of the & and then what is right of the &
      tempStringLeft = Left(textTBarSubMenu,instringLoc - 1)
      tempStringRight = Right(textTBarSubMenu, lenString - instringLoc)
      textTBarSubMenu = tempStringLeft & tempStringRight
    End Select
    ''Check if the displayed text matches the requrested submenu item
    If  Cstr(trim(textTBarSubMenu)) = Cstr(trim(nameSpecifiedToolBarSubMenu)) Then
     Set objectTBarSubMenu = objectTBarMenu.Tools.GetItem(loopSubMenus) 'Set the object only if correct object is found
     booleanToolBarSubMenuFound = True
     Exit For
    End If
   Next
   If booleanToolBarSubMenuFound = False Then
    resultCode = 1
    resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_
     " BUT the submenu of: " & namespecifiedToolBarSubMenu & " WAS NOT DISPLAYED. "
   End If
  Else
   resultCode = 1
   resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_
    "however, NO SUBMENU ITEMS WERE AVAILABLE."
  End If
 End If
 'Start Looking for the SubSubMenu if we found the SubMenu item
 If booleanToolBarSubMenuFound = True Then
  'See if the menu item has any submenu items
  countToolBarSubSubMenus = objectTBarSubMenu.Tools.Count 'Error Object doesn't support this property or method: 'objectTBarSubMenu.Tools'  Line (183): "countToolBarSubSubMenus = objectTBarSubMenu.Tools.Count".
  If  countToolBarSubSubMenus  > 0 Then
   'Check the button and see if we can find the one we specified
   For loopSubSubMenus = 0 to countToolBarSubSubMenus -1
    nameTBarSubSubMenu = objectTBarSubMenu.Tools.GetItem(loopSubSubMenus).Key
    textTBarSubSubMenu = CStr(objectTBarSubMenu.Tools.GetItem(loopSubSubMenus).CaptionResolved)
    stringHotKey ="&"
    'Strip out the & key for the hotkey in the menu item
    instringLoc = InStr(1, textTBarSubMenu, stringHotKey)
    lenString = Len(textTBarSubMenu)
    tempStringLeft = ""
    tempStringRight = ""
    'Use case statement here to work with 0, 1, or else
    Select Case instringLoc
     Case 0
       'Do nothing there is no hotkey
     Case 1
      'Remove the & from the front of the text
      textTBarSubSubMenu = Right(textTBarSubSubMenu, lenString - instringLoc)
     Case Else
      'Build the string by gettting what is left of the & and then what is right of the &
      tempStringLeft = Left(textTBarSubSubMenu,instringLoc - 1)
      tempStringRight = Right(textTBarSubSubMenu, lenString - instringLoc)
      textTBarSubSubMenu = tempStringLeft & tempStringRight
    End Select
    ''Check if the displayed text matches the requrested submenu item
    If  Cstr(trim(textTBarSubSubMenu)) = Cstr(trim(nameSpecifiedToolBarSubSubMenu)) Then
     Set objectTBarSubSubMenu = objectTBarSubMenu.Tools.GetItem(loopSubSubMenus) 'Set the object only if correct object is found
     booleanToolBarSubSubMenuFound = True
     Exit For
    End If
   Next
   If booleanToolBarSubSubMenuFound = True Then
    'Report we found the submenu item
    resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_
     "and the submenu of: " & namespecifiedToolBarSubMenu & " but the sub submenu of: " & nameSpecifiedToolBarSubSubMenu & " WAS DISPLAYED. "
   Else
    resultCode = 1
    resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_
     "and the submenu of: " & namespecifiedToolBarSubMenu & " but the sub submenu of: " & nameSpecifiedToolBarSubSubMenu & " WAS NOT DISPLAYED. "
   End If
  Else
   resultCode = 1
   resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_
    "and the submenu of: " & namespecifiedToolBarSubMenu & "however, NO SUB SUBMENU ITEMS WERE AVAILABLE."
  End If
 End If

 Set objectTBarManager = Nothing 'Temp destroy on exit
 Set objectTBar = Nothing 'Temp destroy on exit
 Set objectTBarMenu = Nothing 'Temp destroy on exit
 CommonTMSSelectToolBarMenuItemTwoLevels = resultCode
End Function