forked from farishadi/Excel_Macro_References
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAPControlGridViewWithFindFunction
More file actions
41 lines (29 loc) · 1.26 KB
/
SAPControlGridViewWithFindFunction
File metadata and controls
41 lines (29 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'Click find in the shell session
session.findById("wnd[1]/tbar[0]/btn[71]").press
'look for "P1" keyword and click exact word search
session.findById("wnd[2]/usr/txtGS_SEARCH-VALUE").Text = "P1"
session.findById("wnd[2]/usr/chkGS_SEARCH-EXACT_WORD").Selected = True
'click execute
session.findById("wnd[2]/tbar[0]/btn[0]").press
'if keyword is found
If Left(session.findById("wnd[0]/sbar").Text, 3) = "Hit" Then
'close find window
session.findById("wnd[2]/tbar[0]/btn[12]").press
'correct cell is already selected and highlighted by system. Double click/click choose
session.findById("wnd[1]/tbar[0]/btn[0]").press
'click execute in primary SAP window
session.findById("wnd[0]/tbar[1]/btn[8]").press
'if keyword is not found
ElseIf session.findById("wnd[0]/sbar").Text = "No Hit Found" Then
'close find window
session.findById("wnd[2]/tbar[0]/btn[12]").press
'close shell window
session.findById("wnd[1]/tbar[0]/btn[12]").press
'go back to home screen
session.findById("wnd[0]/tbar[0]/btn[12]").press
'unsuppress alerts
Application.DisplayAlerts = True
'Display error to user
MsgBox """P1"" User Group not found in SAP List! Contact Macro creator.", , "ERROR!"
End
End If