Buy Now & Pricing Download iMacros Search:
Home Products Purchase Service & Support Partner Programs Contact Us
 iMacros
  Product Information
Success Stories NEW
Compare Editions
Web Image Recognition
Press Reviews NEW
System Requirements
Online User Manual
Product Flyer (PDF)
  Support
Online Demos
Code Samples
Tutorials
iMacros User Forum
  FAQ
  Buy iMacros
  Customer Login
  Support Ticket
   
 
   
   
Home > iMacros >
VBS Sample Code

Click here to download this VBS file (This file is part of the iMacros Trial version)

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)

 


 
 
 
©2000-2009 iOpus Inc., Pat. Pending
| Search Website | Purchase iMacros | Community Forums | Subscribe to iOpus News
 

Site performance and uptime monitored by AlertFox Website Monitoring -> View our current performance.
AlertFox's unique web transaction monitoring is powered by iMacros Web Test Automation.