Start from Web Page
Top  Previous  Next

The following code example shows you how to start a macro from within a web page using Visual Basic Script and the Scripting Interface:

<html>
<head>
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub test()
  Dim WSHShell, iim1, iret
  Set WSHShell = CreateObject("WScript.Shell")
    
  MsgBox ("This example starts a macro from within a web page")

  Set iim1 = CreateObject ("InternetMacros.iim")


  iret = iim1.iimInit()

  iret = iim1.iimDisplay("Start Macro now")

  iret = iim1.iimPlay("Demo-Frame")

  If iret < 0 Then
    MsgBox iim1.iimGetLastError()
  End If

  iret = iim1.iimDisplay("Done!")
  iret = iim1.iimExit()

End Sub
-->
</SCRIPT>
</head>
<body>
<p><a onclick=test()
 href="#">Click here to start script</a></p>
</body>
</html>


To test this code, simply save it as .HTM file and view it in your web browser. Make sure to allow the execution of scripting content on web pages.

In this example, iMacros needs to be installed locally. It will run on the client. This is contract to the ASP example, where iMacros runs on the server (invisible to the user).



Page URL http://www.iopus.com/imacros/help/startmacrofromwebpage.htm