I need to perform Right Click in the Middle of WpfTable, then WpfMenu appears and I want to select a particular Option from it.
See the Screenshot for more details:-
Here is Code I am trying:-
Function IncidentCancellAllActions()
Dim Rowcnt
Rowcnt = SwfWindow("VisionCommandClient").SwfObject("VisionCC_Incident_ActionsTab_SWO").WpfWindow("VisionCC_Incident_ActionsTab_WpfWin").WpfTable("VisionCC_Incident_ActionsTab_WpfTable").RowCount
If Rowcnt > 0 Then
SwfWindow("VisionCommandClient").SwfObject("VisionCC_Incident_ActionsTab_SWO").WpfWindow("VisionCC_Incident_ActionsTab_WpfWin").WpfTable("VisionCC_Incident_ActionsTab_WpfTable").ActivateCell
SendFromKeyboard("1-SHFT-F10")
wait 5
'SwfWindow("VisionCommandClient").WpfWindow("VisionCC_ResourceStatusList_WpfWin_2").WpfMenu("VisionCC_Action_WPM").Select "Cancel All"
msgbox SwfWindow("VisionCommandClient").WpfWindow("VisionCC_ResourceStatusList_WpfWin_2").WpfMenu("VisionCC_Action_WPM").ShowContextMenu
SwfWindow("VisionCommandClient").WpfWindow("VisionCC_ResourceStatusList_WpfWin_2").WpfMenu("VisionCC_Action_WPM").Select "Cancel All"
wait 2
Else
Exit Function
End If
End Function
After right Click, It is not clicking on WpfMenu option "Cancell All".
Had this problem and currently working around the problem using '.Type' method:
WpfWindow("MyWindow").WpfButton("Item-Menu").ShowContextMenu
WpfWindow("MyWindow").WpfMenu("List-Menu").Exist(1)
menuItems = WpfWindow("MyWindow").WpfMenu("List-Menu").GetVisibleText
menuItems = replace(menuItems, chr(13),"")
for each menuItem in split(menuItems,chr(10))
WpfWindow("SAP Work Manager").WpfMenu("List-Menu").Type micDwn
Wait 0,400
If instr(1, menuItem, "MenuItemToClick") > 0 Then 'replace MenuItemToClick with the menu item text.
Exit for
End If
next
WpfWindow("SAP Work Manager").WpfMenu("List-Menu").Type micReturn
This works as long as the order of menu items doesn't change. Waits are included because ive noticed HP-UFT doesn't check that the object is fully loaded before doing the next task.
Related
I've two Input Fields and Two Submit Button on a page.
InputField1 "Code"
InputField2 "Amount"
Button1 "Save"
Button2 "Save And Add Another"
Having trouble writing the logic. i should only hit save when i've only one item item and move on. if mutltiple then i need to hit button2 and follow the process and at the end i need to hit save. Any help will be highly apreciated. I'm just not sure how do i handle the save button.
sCode="100:500"
sAmount="500:500"
arrCCode=Split(sCode,":")
arrAmount=Split(sAmount,":")
For i = 0 To UBound(arrCCode)
If i > UBound(arrCCode) Then
Exit For
Else
MsgBox arrCCod(i)
MsgBox arrAmount(i)
End If
Next
I think i got it,,,
sCode="100:500"
sAmount="500:500"
arrCCode=Split(sCode,":")
arrAmount=Split(sAmount,":")
For i = 0 To UBound(arrCCode)
'If i > UBound(arrCCode) Then
'Exit For
'Else
MsgBox arrCCod(i)
MsgBox arrAmount(i)
If i = UBound(arrCCod) Then
msgbox "Save"
Exit For
Else
Msgbox "Save and add"
End
'End If
Next
When I click the a command button to close the form, the code requery's a cbo and listbox, moves the focus to the lstbox and a particular row. What I need to do is add some code that "clicks" the current row in the listbox that has the focus.
Here is the code I have on the click event.
If Forms![frmmain]![txtHidden] = "addok" Then
Forms![frmmain]![cboAuthor].Requery
Forms![frmmain]![LstAuthor].Requery
Forms![frmmain]![LstAuthor] = Me.AuthorID
Forms![frmmain]![txtHidden] = "AddDone"
DoCmd.Close acForm, "frmAddAuthorFly"
Forms![frmmain]![cboAuthor].Requery
Forms![frmmain]![LstAuthor].Requery
Forms![frmmain].[LstAuthor].SetFocus
<NEED TO INSERT SOMETHING HERE TO CLICK THE ROW"
Else
MsgBox "txt hidden is not addok"
DoCmd.Close acForm, "frmaddauthorfly"
End If
A click does nothing by itself, but you may have some OnClick code that runs. To do so, just call the OnClick event.
But all this requiring - and indeed "clicking" - shouldn't be needed; it seems as if you need to rethink your concept.
I am working with Power Point 2007 but there is no Add Ins menu tab and I can not find how to add it.
When PPT 2007 and onward runs code that creates "legacy" command bars or menu modifications, it automatically adds the Add-ins tab to the ribbon and puts the command bars/menu changes there. Here's some simple example code. You can run it as is, or save it as an add-in. Once the add-in is loaded, the Auto_Open code will run every time PPT starts up.
Sub Auto_Open()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim MyToolbar As String
' Give the toolbar a name
MyToolbar = "Kewl Tools"
On Error Resume Next
' so that it doesn't stop on the next line if the toolbar's already there
' Create the toolbar; PowerPoint will error if it already exists
Set oToolbar = CommandBars.Add(Name:=MyToolbar, _
Position:=msoBarFloating, Temporary:=True)
If Err.Number <> 0 Then
' The toolbar's already there, so we have nothing to do
Exit Sub
End If
On Error GoTo ErrorHandler
' Now add a button to the new toolbar
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
' And set some of the button's properties
With oButton
.DescriptionText = "This is my first button"
'Tooltip text when mouse if placed over button
.Caption = "Do Button1 Stuff"
'Text if Text in Icon is chosen
.OnAction = "Button1"
'Runs the Sub Button1() code when clicked
.Style = msoButtonIcon
' Button displays as icon, not text or both
.FaceId = 52
' chooses icon #52 from the available Office icons
End With
' Repeat the above for as many more buttons as you need to add
' Be sure to change the .OnAction property at least for each new button
' You can set the toolbar position and visibility here if you like
' By default, it'll be visible when created. Position will be ignored in PPT 2007 and later
oToolbar.Top = 150
oToolbar.Left = 150
oToolbar.Visible = True
NormalExit:
Exit Sub ' so it doesn't go on to run the errorhandler code
ErrorHandler:
'Just in case there is an error
MsgBox Err.Number & vbCrLf & Err.Description
Resume NormalExit:
End Sub
Sub Button1()
' This code will run when you click Button 1 added above
' Add a similar subroutine for each additional button you create on the toolbar
' This is just some silly example code.
' You'd put your real working code here to do whatever
' it is that you want to do
MsgBox "Stop poking the pig!"
End Sub
I made a form and created a command button control. I would like to make it so that when the user presses the command button it sends a keystroke to a listbox of my choice.
Specifically, I want the command button to send a "down" arrow keystroke to a listbox (which will have focus) so that it goes from the current item to the next item.
How do I do this?
Let's say the name of my listbox is "lstFruits". I gave it focus, then tried SendKey.
Form.lstFruits.SetFocus.
SendKeys.Send ("{DOWN}")
Got the error "Argument not optional".
There is no need to emulate a keystroke, you can control the listbox in code;
lstFruits.SetFocus
if ((lstFruits.listindex + 1) < lstFruits.listcount) then
lstFruits.listindex = lstFruits.listindex+ 1
endif
Edit
Dim strName As String
strName = "lstFruits"
Dim lst As VB.ListBox: Set lst = TheForm.Controls(strName)
lst.SetFocus
If ((lst.ListIndex + 1) < lst.ListCount) Then
lst.ListIndex = lst.ListIndex + 1
End If
In VB6 I need to know how to call a button click event on anther form. The another form part is easy but how to pass the click event the proper method to "click" the right button on the toolbar is the real issue.
Here is the vent on the main form - i need to call the click event case "Copyfrom".
MainForm
Public Sub tbrMain_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case ToolBarItem.tbPrint
'(some code)
Case ToolBarItem.tbSave
'(some code)
Case ToolBarItem.tbCopyFrom
'(some code)
Case ToolBarItem.tbNEW
'(etc)
I tried
Mainform.tbrMain_ButtonClick()
and even tried passing the index number and key - no dice.
The event handler is expecting to receive a reference to an actual toolbar button, so you have to pass the toolbar button itself, not it's Caption or Key, e.g.:
Form1.tbrMain_ButtonClick Form1.tbrMain.Buttons(1)
Or, using the Call statement:
Call Form1.tbrMain_ButtonClick(Form1.tbrMain.Buttons(1))
If you set the Key properties on your toolbar buttons, you can use the Key property of the desired button in place of the (1):
Form1.tbrMain_ButtonClick Form1.tbrMain.Buttons("PrintButton")
Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
If ButtonMenu.Key = "A" Then
MsgBox "Button-1"
ElseIf ButtonMenu.Key = "B" Then
MsgBox "Button -2"
ElseIf ButtonMenu.Key = "C" Then
MsgBox "Button -3"
ElseIf ButtonMenu.Key = "D" Then
MsgBox "Button -4"
ElseIf ButtonMenu.Key = "E" Then
MsgBox "Button -5"
End If
End Sub