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
This script takes values from a comma separated variable 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
Option Explicit MsgBox "This script demonstrates how to read data from a simple text file and submit this information to a website. It reads from the file <IIM-TEST-SUBMIT.CSV> file and uses the macro <wsh-submit-2-web.iim>." + vbCrLf + VbCrLf + "Tip: This script has the same function as <database-2-web.vbs> script but uses a text file instead of a database as input." + vbCrLf + VbCrLf + "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") 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 ("InternetMacros.iim") iret = iim1.iimInit iret = iim1.iimDisplay("Submitting Data") do until rs.eof 'Set the variables iret = iim1.iimSet("-var_FNAME", rs.fields(0)) iret = iim1.iimSet("-var_LNAME", rs.fields(1)) iret = iim1.iimSet("-var_ADDRESS", rs.fields(2)) iret = iim1.iimSet("-var_CITY", rs.fields(3)) iret = iim1.iimSet("-var_ZIP", rs.fields(4)) iret = iim1.iimSet("-var_STATE-ID", rs.fields(5)) iret = iim1.iimSet("-var_COUNTRY-ID", rs.fields(6)) iret = iim1.iimSet("-var_EMAIL", rs.fields(7)) 'Run the macro 'Same macro as in database-2-web.vbs example!!! iret = iim1.iimPlay("wsh-submit-2-web") If iret < 0 Then MsgBox iim1.iimGetLastError() End If rs.movenext loop iret = iim1.iimDisplay("Done!") iret = iim1.iimExit WScript.Quit(0)
Macro code for Wsh-Submit-2-Web:
VERSION BUILD=3700331 TAB T=1 TAB CLOSEALLOTHERS 'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database ' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file 'CSV = Comma Separated Values in each line of the file CMDLINE !DATASOURCE address.csv 'Number of columns in the CSV file. This must be accurate! SET !DATASOURCE_COLUMNS 8 'Increase the current position in the file with each loop SET !DATASOURCE_LINE {{!LOOP}} ' ' Fill web form URL GOTO=http://www.iopus.com/imacros/demo/v5/f2/automatic-data-entry.asp TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:FNAME CONTENT={{!COL1}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:LNAME CONTENT={{!COL2}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:ADDRESS CONTENT={{!COL3}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:CITY CONTENT={{!COL4}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:ZIP CONTENT={{!COL5}} '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=NAME:WebDataEntry ATTR=NAME:STATEID CONTENT=$*{{!COL6}}* TAG POS=1 TYPE=SELECT FORM=NAME:WebDataEntry ATTR=NAME:COUNTRYID CONTENT=$*{{!COL7}}* TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:EMAIL CONTENT={{!COL8}} TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:WebDataEntry ATTR=NAME:SendButton&&VALUE:Click<SP>to<SP>submit<SP>data TAG POS=1 TYPE=A ATTR=TXT:Back