on 05-15-2014 8:09 PM
Hi every Experts!
I am looking some VBA script for my search results.
I am searching a value ;
.findById("wnd[0]").maximize
.findById("wnd[0]").sendVKey 71
.findById("wnd[1]/usr/txtRSYSF-STRING").Text = "6306"
.findById("wnd[1]/usr/txtRSYSF-STRING").caretPosition = 6
.findById("wnd[1]").sendVKey 0
If the search results that I found then this code will copy and paste into my excel ;
.findById("wnd[2]/usr/lbl[5,2]").SetFocus
.findById("wnd[2]/usr/lbl[5,2]").caretPosition = 2
.findById("wnd[2]/usr/lbl[48,2]").SetFocus
.findById("wnd[2]/usr/lbl[48,2]").caretPosition = 6
Sheet2.Cells(22, 4) = .findById("wnd[2]/usr/lbl[5,2]").Text
Sheet2.Cells(22, 5) = .findById("wnd[2]/usr/lbl[48,2]").Text
.findById("wnd[1]").sendVKey 0
.findById("wnd[2]/tbar[0]/btn[17]").press
.findById("wnd[1]/tbar[0]/btn[12]").press
But If I don’t have any search results then it’s says "Search unsuccessful - no hits found for: 6306" ;
.findById("wnd[2]/usr/txtMESSTXT1").caretPosition = 4
.findById("wnd[2]/tbar[0]/btn[0]").press
.findById("wnd[1]/tbar[0]/btn[12]").press
Is there any way I can do If and else function? Or I can do another statement? (IF or Else) or argument ? something like that , I want combine this all together.
Thanks all,
Hi Raw,
you can try e.g. the following:
.findById("wnd[0]").maximize
.findById("wnd[0]").sendVKey 71
.findById("wnd[1]/usr/txtRSYSF-STRING").Text = "6306"
.findById("wnd[1]/usr/txtRSYSF-STRING").caretPosition = 6
.findById("wnd[1]").sendVKey 0
Information = ""
on error resume next
Information = .findById("wnd[2]").Text
on error goto 0
if Information <> "Information" then
If the search results that I found then this code will copy and paste into my excel ;
.findById("wnd[2]/usr/lbl[5,2]").SetFocus
.findById("wnd[2]/usr/lbl[5,2]").caretPosition = 2
.findById("wnd[2]/usr/lbl[48,2]").SetFocus
.findById("wnd[2]/usr/lbl[48,2]").caretPosition = 6
Sheet2.Cells(22, 4) = .findById("wnd[2]/usr/lbl[5,2]").Text
Sheet2.Cells(22, 5) = .findById("wnd[2]/usr/lbl[48,2]").Text
.findById("wnd[1]").sendVKey 0
.findById("wnd[2]/tbar[0]/btn[17]").press
.findById("wnd[1]/tbar[0]/btn[12]").press
else
But If I don’t have any search results then it’s says "Search unsuccessful - no hits found for: 6306" ;
.findById("wnd[2]/usr/txtMESSTXT1").caretPosition = 4
.findById("wnd[2]/tbar[0]/btn[0]").press
.findById("wnd[1]/tbar[0]/btn[12]").press
end if
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.