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 menusSet objectToolBar =objectMainPage.SwfToolbar("_toolbarsDockAreaTop")specifiedToolBar = "Desktop Menu"specfiiedToolBarMenuItem = "Bond Definition" 'This is what the text that you see is without the shortcut keybonspecifiedToolBarSubMenu = "Validate" 'Text is case sensitivespecifiedToolBarSubSubMenu = "Details..." 'Text is case sensitivenameToolBar = "" 'Toolbar namenameToolBarMenu = "" 'Toolbar main menu itemnameToolBarMenuSubMenu = "" 'The submenu namenameToolBarMenuSubSubMenu = "" 'The submenu nameobjectToolBarSubSubmenu = "" 'The object to recieve the subsubmenu object for validation of enabled etc properties in the calling scriptreporterDetailsFuncSelectToolBar = ""'Get the toolbar text/name with the toolbarbutton text/nameeventCodeFuncSelectToolBarMenu = 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 TabElse eventCode = 1 eventLoopCode = 1 reporterDetails = reporterDetails & reporterDetailsFuncSelectToolBarEnd 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 = resultCodeEnd Function
Hello Brian,
The ClickMenuTool function takes two parameters; this is why you are seeing the comma you highlighted in your last update. The string delimited by the first set of quotes identifies the menu which contains the tool that you want clicked. The second string identifies the tool itself. In order for the ClickMenuTool function to work properly, you need to pass two strings to it. What you've been trying to do is pass just one string to it. Try passing two strings in the same way that it gets recorded and see if it works.
Hi Dave,
Unfortunately we cannot get you a sample of the menu code from the third party supplier. The function I have given you the code for in the forum is an extension of the following menu code which works to get the second level menu as noted below. This code was built using information from the Infragistic site. Do you have menus like this in your sample applications which we could use to see if we can get to the next level of menus?
Any help on getting this done would be appreciated.
Brian.
' @Function Name CommonTMSSelectToolBarMenuItem' @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"'SwfWindow("Summit FT - Calendar Definition").SwfToolbar("_toolbarsDockAreaTop").ClickMenuTool "Desktop Menu,57:EntityView","60:Open"' 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 CommonTMSSelectToolBarMenuItem(byVal objectPageToolBar, byVal nameSpecifiedToolBar, byRef nameSpecifiedToolBarMenu, ByRef nameSpecifiedToolBarSubMenu, byRef nameTBar, byRef nameTBarMenu, byRef nameTBarSubMenu, ByRef objectTBarSubMenu, 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 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 = 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 = 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 booleanToolBarSubMenuFound = True Exit For End If Next 'See if we have found the submenu item If booleanToolBarSubMenuFound = True Then Set objectTBarSubMenu = objectTBarMenu.Tools.GetItem(loopSubMenus) 'Set the object only if correct object is found resultCode = 0 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_ " and the submenu of: " & namespecifiedToolBarSubMenu & " was displayed. " Else 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 Else resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " BUT THE MENU 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 Else 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 Set objectTBarManager = Nothing 'Temp destroy on exit Set objectTBar = Nothing 'Temp destroy on exit Set objectTBarMenu = Nothing 'Temp destroy on exit CommonTMSSelectToolBarMenuItem = resultCodeEnd Function
In order for me to really be able to help you with this, I would need a sample application and script which reproduces the issue. Once you have everything in one ZIP file, you can attach it to a post by selecting the Options tab before submitting your post.
Hi Michael and David,
I am inserting a screen capture of the menu that I am trying to work with. This does not appear to be anything which is unique or different from the other levels of the menu that I have been able to work with successfully. Please let me know what else we can try to get this menu so we can select it.
A ticket has been opened, and it could be useful if you contacted our developer support directly on this matter. The issue from what I can tell is that you are getting an exception:'Error Object doesn't support this property or method: 'objectTBarSubMenu.Tools' Line (183): "countToolBarSubSubMenus = objectTBarSubMenu.Tools.Count". It is basically saying that the subMenu object that you retrieved does not have a Tools property. Since I imagine you were expecting some form of PopUpMenu, which would have a Tools property, then likely the Tool you grabbed is not a PopUpMenu tool.
Why it isn't I cannot say, I can say possibilities, one of which is the Tool you grabbed, is an MdiPlaceHolderTool, which is used when the actually tool you want is housed on a parent form and not on the child form that you are interacting with. To access the tool you want, you need to see if the UnderlyingTool property has a value or not, and if so get the Tools property of that.This of course is typically really only a possibility if you have a form within another form, in which the parent form has the same tool in it even if you closed the child form.
It could also be some flaw in how you are getting the subMenu, it's honestly hard for me to tell without walking through it, but again I would suggest checking to see if the CaptionResolved is what you believe it to be. If it is, and it using UnderlyingTool does not resolve it, then I would recommend contacting our DeveloperSupport to have them walk through it with you.