Exit script if account not found and move to next

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Jaffey
Posts: 31
Joined: Tue Jul 13, 2010 11:59 am
Location: Toronto, Canada

Exit script if account not found and move to next

Post by Jaffey » Wed Aug 12, 2020 8:43 pm

Greetings,

I have a VB script that runs an "open account" imacro that pulls up accounts in a web portal and then runs another imacro script to extract various fields. It works well enough but the problem is, if the account in question is not found, it continues to run the extract script. What I would like it to do is abort/exit if the account can not be pulled up and continue to the next account while entering "not found" beside the offending entry. Thank you!

My setup details are:

Microsoft Windows 10 Home
64-bit Operating System
Installed UI Culture: English (Canada)
Internet Explorer version 9.11.18362.0
iMacros version 8.0.3.2216 (don't hate me)

The scripts I am using look like this:

Open Account imacro
set !TIMEOUT_STEP 1
SET !ERRORIGNORE YES

FRAME NAME=main

'INITIAL SCREEN
TAG POS=1 TYPE=NOBR FORM=NAME:form1 ATTR=TXT:Lookup
TAG POS=1 TYPE=NOBR FORM=NAME:frmPrimary ATTR=TXT:Lookup
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:Lookup ATTR=NAME:txtEstateNumber CONTENT={{Acct#}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:Lookup ATTR=NAME:btnSearch
' click claim button/OPEN ACCOUNT
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:Lookup ATTR=NAME:dgPostSetup$ctl02$ClaimCode

Get Account Details

set !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
FRAME NAME=main
'set !replayspeed medium

'Bank's Name - THIS IS ALSO THE LINK TO DETAILS SCREEN
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:frmPrimary ATTR=NAME:dgParty$ctl02$bthParty EXTRACT = TXT
'BANK TYPE
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtBankruptcyType EXTRACT = TXT
'Trustee
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtTrusteeName EXTRACT = TXT
'CONTACT NAME DROPDOWN
TAG POS=1 TYPE=SELECT FORM=NAME:frmPrimary ATTR=NAME:ddlContact EXTRACT = TXT
'REQUEST STATUS DROPDOWN
TAG POS=1 TYPE=SELECT FORM=NAME:frmPrimary ATTR=NAME:ddlRequest EXTRACT = TXT
'Status
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtStatus EXTRACT = TXT
'Status Date
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtStatusDatebox EXTRACT = TXT
'Status Days
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtStatDay EXTRACT = TXT
'Urgent note!
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtFlag1 EXTRACT = TXT
'Instruction Date
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtInstructDatebox EXTRACT = TXT
'Instruction Days
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtInsDay EXTRACT = TXT

'========GET ACCOUNT DETAILS MENU CONTROL 2============
'TAGS NOT WORKING, HAVE TO USE DIRECT SCREEN
'SIZE X=1071 Y=837
DS CMD=CLICK X=356 Y=21
WAIT SECONDS=1
DS CMD=CLICK X=355 Y=65
'=================

FRAME NAME=main
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtBankruptBalance EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtBankruptDate EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtOutstanding EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtLoanNum EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtOtherNum EXTRACT = TXT
TAG POS=1 TYPE=SELECT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$ddlProduct EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtOwing EXTRACT = TXT
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:frmAccountInfo ATTR=NAME:btnExit

VB script

Code: Select all

Sub LOGIN_GET_FILE_DETAILS()
    Dim iim1, iret, row, totalrows, iim, FirstRow, c, xx
    Dim oSh As Worksheet
    Set oSh = ActiveSheet
    Set iim1 = CreateObject("imacros")
    iret = iim1.iimInit
    
    iim1.iimPlay ("D:\OneDrive\iMacros\Login.iim")

    DoEvents
    
     FirstRow = ActiveSheet.Range("p1")
    totalrows = ActiveSheet.Range("q1")

   For row = FirstRow To totalrows
    c = 13 ' c = column start number
    x = 1 ' x = extract#
    xx = 1 ' loop counter for saving every 100 loops
    
     iret = iim1.iimSet("Acct#", Cells(row, 3).value)
     iret = iim1.iimPlay("D:\OneDrive\iMacros\Teranet\TeranetOpenAccount.iim")
     iret = iim1.iimPlay("D:\OneDrive\iMacros\Teranet\Teranet_GET_ALL_DETAILS.iim")
    
     'iret = iim1.iimSet("-tray", "") 'iim1.iimSet("-silent", "")
    
     Cells(row, c).value = Replace(iim1.iimGetLastExtract(x), "[EXTRACT]", "")
     c = c + 1
     x = x + 1
     Cells(row, c).value = Replace(iim1.iimGetLastExtract(x), "[EXTRACT]", "")
     c = c + 1
     x = x + 1
 

    Next row
    
 oSh.ListObjects(1).DataBodyRange.WrapText = False

Application.ScreenUpdating = True
Application.EnableEvents = True

  
End Sub
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Exit script if account not found and move to next

Post by chivracq » Wed Aug 12, 2020 9:02 pm

Jaffey wrote:
Wed Aug 12, 2020 8:43 pm
Greetings,

I have a VB script that runs an "open account" imacro that pulls up accounts in a web portal and then runs another imacro script to extract various fields. It works well enough but the problem is, if the account in question is not found, it continues to run the extract script. What I would like it to do is abort/exit if the account can not be pulled up and continue to the next account while entering "not found" beside the offending entry. Thank you!

My setup details are:

Code: Select all

Microsoft Windows 10 Home
64-bit Operating System
Installed UI Culture: English (Canada)
Internet Explorer version 9.11.18362.0
iMacros version 8.0.3.2216 (don't hate me)
The scripts I am using look like this:

Open Account imacro

Code: Select all

set !TIMEOUT_STEP 1
SET !ERRORIGNORE YES

FRAME NAME=main

'INITIAL SCREEN 
TAG POS=1 TYPE=NOBR FORM=NAME:form1 ATTR=TXT:Lookup
 TAG POS=1 TYPE=NOBR FORM=NAME:frmPrimary ATTR=TXT:Lookup 
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:Lookup ATTR=NAME:txtEstateNumber CONTENT={{Acct#}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:Lookup ATTR=NAME:btnSearch
' click claim button/OPEN ACCOUNT
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:Lookup ATTR=NAME:dgPostSetup$ctl02$ClaimCode
Get Account Details

Code: Select all

set !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
FRAME NAME=main
'set !replayspeed medium

'Bank's Name - THIS IS ALSO THE LINK TO DETAILS SCREEN
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:frmPrimary ATTR=NAME:dgParty$ctl02$bthParty EXTRACT = TXT
'BANK TYPE
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtBankruptcyType EXTRACT = TXT
'Trustee 
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtTrusteeName EXTRACT = TXT
'CONTACT NAME DROPDOWN
TAG POS=1 TYPE=SELECT FORM=NAME:frmPrimary ATTR=NAME:ddlContact  EXTRACT = TXT
'REQUEST STATUS DROPDOWN
TAG POS=1 TYPE=SELECT FORM=NAME:frmPrimary ATTR=NAME:ddlRequest EXTRACT = TXT
'Status 
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtStatus EXTRACT = TXT
'Status Date
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtStatusDatebox EXTRACT = TXT
'Status Days
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtStatDay EXTRACT = TXT
'Urgent note! 
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtFlag1 EXTRACT = TXT
'Instruction Date
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtInstructDatebox EXTRACT = TXT
'Instruction Days
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmPrimary ATTR=NAME:txtInsDay EXTRACT = TXT

'========GET ACCOUNT DETAILS MENU CONTROL 2============
'TAGS NOT WORKING, HAVE TO USE DIRECT SCREEN
'SIZE X=1071 Y=837
DS CMD=CLICK X=356 Y=21
WAIT SECONDS=1
DS CMD=CLICK X=355 Y=65
'=================

FRAME NAME=main
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtBankruptBalance EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtBankruptDate EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtOutstanding EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtLoanNum EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtOtherNum EXTRACT = TXT
TAG POS=1 TYPE=SELECT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$ddlProduct EXTRACT = TXT
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:frmAccountInfo ATTR=NAME:ctl04$txtOwing EXTRACT = TXT
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:frmAccountInfo ATTR=NAME:btnExit
VB script

Code: Select all

Sub LOGIN_GET_FILE_DETAILS()
    Dim iim1, iret, row, totalrows, iim, FirstRow, c, xx
    Dim oSh As Worksheet
    Set oSh = ActiveSheet
    Set iim1 = CreateObject("imacros")
    iret = iim1.iimInit
    
    iim1.iimPlay ("D:\OneDrive\iMacros\Login.iim")

    DoEvents
    
     FirstRow = ActiveSheet.Range("p1")
    totalrows = ActiveSheet.Range("q1")

   For row = FirstRow To totalrows
    c = 13 ' c = column start number
    x = 1 ' x = extract#
    xx = 1 ' loop counter for saving every 100 loops
    
     iret = iim1.iimSet("Acct#", Cells(row, 3).value)
     iret = iim1.iimPlay("D:\OneDrive\iMacros\Teranet\TeranetOpenAccount.iim")
     iret = iim1.iimPlay("D:\OneDrive\iMacros\Teranet\Teranet_GET_ALL_DETAILS.iim")
    
     'iret = iim1.iimSet("-tray", "") 'iim1.iimSet("-silent", "")
    
     Cells(row, c).value = Replace(iim1.iimGetLastExtract(x), "[EXTRACT]", "")
     c = c + 1
     x = x + 1
     Cells(row, c).value = Replace(iim1.iimGetLastExtract(x), "[EXTRACT]", "")
     c = c + 1
     x = x + 1
 

    Next row
    
 oSh.ListObjects(1).DataBodyRange.WrapText = False

Application.ScreenUpdating = True
Application.EnableEvents = True

  
End Sub

Hum..., OK... I've seen your Thread, ... which looks Interesting, and with very good Quality... :D , but I guess I will "pass" on this one, as you never followed up on your previous Thread... :shock:

Too bad, but I don't (try to) help anymore when Users don't follow up, tja...! :|
OK, good "Luck" anyway with other Advanced Users...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Exit script if account not found and move to next

Post by chivracq » Thu Aug 27, 2020 8:34 am

chivracq wrote:
Wed Aug 12, 2020 9:02 pm
... but I guess I will "pass" on this one, as you never followed up on your previous Thread... :shock:

Hum..., and no Follow-up on this one either... :shock:
I don't "really" see "the point" of asking for Help on a Tech Forum for Users who then don't check/don't follow up on their Threads... :roll:
OK, never mind... :|
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply