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
File-2-Web-Method2.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 script takes values from a comma separated value file (.csv) using the Microsoft Text File Driver. It calls the macro Wsh-Submit-2-Web, passing values to the macro using the iimSet command.
For more information on using the Microsoft Text Driver search for "Text File Driver" and "Schema.ini" in any search engine
' iMacros File-2-Web-Method2 Script ' (c) 2008-2015 iOpus/Ipswitch Inc. Option Explicit Dim message message = "This script demonstrates how to read data from a simple text file and submit this information to a website." message = message + " It reads from the file <IIM-TEST-SUBMIT.CSV> and uses the macro <wsh-submit-2-web.iim>." + vbCrLf + VbCrLf message = message + "Tip: This script has the same function as <database-2-web.vbs> but uses a text file instead of a database as input." + vbCrLf + VbCrLf message = message + "Note: If you change the file name of the input text file, you also need to change it in the <schema.ini> file." 'Tip: For more information on the method used here 'search for "Text File Driver" and "Schema.ini" in any search engine 'Note: On some language versions of Windows (e.g. German (Deutsch)) CSV data is separated by semicolons (;) 'and not a comma (,). This this case you need to replace all "," by ";" in the input file ("iimsubmit.csv") Dim rs, sDir, strConnect Dim iim1, iret set rs = createobject("ador.recordset") 'Note for x64 users: You must start the VBS script in 32bit mode (C:\Windows\SysWOW64\wscript.exe) for the Microsoft ODBC Driver to work 'Please see the note about VBS scripts on http://wiki.imacros.net/x64 for more details sDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "") 'Get current directory strConnect = _ "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _ "DefaultDir=" & sDir & ";" Const adOpenStatic = 3 rs.open "select * from iimsubmit.csv", strConnect, adOpenStatic MsgBox "Input file information:" & vbCrLf & vbCrLf & _ "Recordcount: " & rs.recordcount & vbCrLf & vbCrLf & _ "Fields per record: " & rs.fields.count set iim1= CreateObject ("imacros") iret = iim1.iimOpen iret = iim1.iimDisplay("Submitting Data") do until rs.eof 'Set the variables iret = iim1.iimSet("FNAME", rs.fields(0)) iret = iim1.iimSet("LNAME", rs.fields(1)) iret = iim1.iimSet("ADDRESS", rs.fields(2)) iret = iim1.iimSet("CITY", rs.fields(3)) iret = iim1.iimSet("ZIP", rs.fields(4)) iret = iim1.iimSet("STATE-ID", rs.fields(5)) iret = iim1.iimSet("COUNTRY-ID", rs.fields(6)) iret = iim1.iimSet("EMAIL", rs.fields(7)) 'Run the macro 'Same macro as in database-2-web.vbs example!!! iret = iim1.iimPlay(sDir & "Macros\wsh-submit-2-web.iim") If iret < 0 Then MsgBox "Error code: "+cstr(iret) + VbCrLf + "Error Text: "+iim1. iimGetErrorText() End If rs.movenext loop iret = iim1.iimDisplay("Done!") iret = iim1.iimClose WScript.Quit(iret)
Macro code for Wsh-Submit-2-Web:
TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:fname CONTENT={{FNAME}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:lname CONTENT={{LNAME}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:address CONTENT={{ADDRESS}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:city CONTENT={{CITY}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:zip CONTENT={{ZIP}} 'Tip: Use the string ($) instead of the index to select the state and country 'Index would be the position of an entry in the combo box list, e. g. 161 for United States 'The $ option is more robust against changes of the combo box content 'Note * is used to ignore leading and trailing blanks that could be in the input data TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:state CONTENT=$*{{STATE-ID}}* TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:country CONTENT=$*{{COUNTRY-ID}}* TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:email CONTENT={{EMAIL}} TAG POS=1 TYPE=BUTTON:SUBMIT FORM=ID:demo ATTR=TXT:SUBMIT TAG POS=1 TYPE=A ATTR=TXT:*Back*