The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
extract-and-fill.vbs
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
This example script extracts information from one website and uses this to fill a form on another.
Macros used:
- Wsh-Extract-Rate
- Wsh-Extract-And-Fill-Part2
Visual Basic Script:
' iMacros Extract-and-Fill Script ' (c) 2008-2015 iOpus/Ipswitch Inc. Option Explicit Dim value1, value2, s Msgbox ("This example shows how to use a data EXTRACTION and then fill the extracted data into a new form. It uses two macros for this purpose.") ' find current folder Dim myname, mypath myname = WScript.ScriptFullName mypath = Left(myname, InstrRev(myname, "\")) Dim iim1, iret, iplay set iim1= CreateObject ("imacros") iret = iim1.iimOpen("-ng") '--- Extraction starts --- iret = iim1.iimDisplay("Extract Data") iplay = iim1.iimPlay(mypath & "Macros\wsh-extract-rate.iim") If iplay < 0 Then s = "The following error occurred: " + vbCrLf + vbCrLf + iim1.iimGetErrorText() MsgBox s WScript.Quit(iplay) End If '--- Extraction done --- value1 = iim1.iimGetExtract(1) value2 = iim1.iimGetExtract(2) s = "Hello Jim," +vbCrLf + vbCrLf s = s + "Did you know? One US$ costs " + value1 + " EURO or " + value2 + " British Pounds (GBP)." '--- Submission starts --- iret = iim1.iimDisplay("Submit extracted data") iret = iim1.iimSet ("currency", s) iplay = iim1.iimPlay(mypath & "Macros\wsh-extract-and-fill-part2.iim") If iplay < 0 Then MsgBox "Error code: "+cstr(iplay) + VbCrLf + "Error Text: "+iim1.iimGetErrorText() End If iret = iim1.iimClose WScript.Quit(iret)
Macro code for Wsh-Extract-Rate:
TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://demo.imacros.net/Automate/ExtractDemo 'Get the values TAG POS=39 TYPE=TD ATTR=TXT:* EXTRACT=TXT TAG POS=40 TYPE=TD ATTR=TXT:* EXTRACT=TXT
Macro code for Wsh-Extract-And-Fill-Part2:
'This macro is the second macro used in the 'extract-and-fill.vbs example TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://demo.imacros.net/Automate/TestForm1 TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:name CONTENT=Tom<SP>Tester TAG POS=1 TYPE=TEXTAREA FORM=ID:demo ATTR=NAME:Remarks CONTENT={{currency}} TAG POS=1 TYPE=BUTTON:SUBMIT FORM=ID:demo ATTR=TXT:Click<SP>to<SP>order<SP>now WAIT SECONDS=3