I'm not sure I'm in the right forum, if there is a better forum, please let me know.

I have to devlop a VBscript pop up, that uses IE as the UI (because the pop up has to display four fields from a database), the displayed fields are verified as correct or corrected by the user and then a simple click on the 'submit' button ends the pop up session.


I have written some code:

VB Code:
  1. 'script to use InterNet Explorer as User Interface
  2. Dim doc, page, strIETitle, oDB
  3. ' Instantiate database class
  4. Set odb = New DataBaseFunctions
  5. strIETitle="On Call Verification Thingie - Ver .60"
  6. fn=WScript.scriptFullName
  7. p=InStrRev(fn,"\")
  8. appldir=Left(fn,p)
  9. Set objShell = CreateObject("WScript.Shell")
  10. Set objIE=WScript.CreateObject("internetexplorer.application","iexplore_")
  11.  
  12. With objIE
  13.    .ToolBar = False
  14.    .StatusBar = False
  15.    .Resizable = False
  16.    .Navigate("about:blank")
  17.    Do Until .readyState = 4
  18.      WScript.Sleep 100
  19.    Loop
  20.    With .document
  21.      With .ParentWindow
  22.        intWidth = .Screen.AvailWidth
  23.        intHeight = .Screen.AvailHeight
  24.        intWidthW = .Screen.AvailWidth * .50
  25.        intHeightW = .Screen.AvailHeight * .38
  26.                                                     ' Was .05
  27.        .resizeto intWidthW, intHeightW
  28.        .moveto (intWidth - intWidthW)/2, (intHeight - intHeightW)/2
  29.      End With
  30.      .Write "<body> " & strMsg & " </body></html>"
  31.      With .ParentWindow.document.body
  32.        .style.backgroundcolor = "LightBlue"
  33.        .scroll="no"
  34.        .style.Font = "10pt 'Courier New'"
  35.        .style.borderStyle = "outset"
  36.        .style.borderWidth = "4px"
  37.      End With
  38.      .Title = strIETitle
  39.      objIE.Visible = True
  40.      WScript.Sleep 100
  41.      objShell.AppActivate strIETitle
  42.    End With
  43.  End With
  44.  
  45.  objIE.visible=True
  46. ' Test sleep below
  47.  WScript.Sleep 6000
  48.  html="oncall.htm"
  49.  loadDocument(html)
  50.  ieLoaded
  51.  bReady=False
  52.  Do
  53.    WScript.sleep(100)
  54.    If html<>"" Then
  55.      loadDocument(html)
  56.      ieLoaded
  57.    End If
  58.  Loop until bReady
  59.  
  60.  
  61.  Set objIE=Nothing
  62.  WScript.Quit
  63.  
  64.  Sub iexplore_onQuit()
  65.    bReady=True
  66.  End Sub
  67.  
  68.  Sub loadDocument(adoc)
  69.    objIE.navigate(appldir & adoc)
  70.    page=adoc
  71.    html=""
  72.    'wait till document loaded
  73.    Do While objIE.readystate<>4
  74.    Loop
  75.     'doc is defined here
  76.    Set doc=objIE.document
  77.  End Sub
  78.  
  79.  Sub iesubmit()
  80.    Select Case page
  81.    Case "oncall.htm"
  82.      ie_form
  83.    Case Else
  84.  
  85.    End Select
  86.    page=doc.forms(0).action
  87.    html=page
  88.  End Sub
  89.  
  90.  Sub ieLoaded()
  91.    Select Case page
  92.      Case "oncall.htm"
  93.         ie_form_loaded
  94.      Case Else
  95.    End Select
  96.  
  97.  End Sub
  98.  
  99.  Sub ie_form()
  100.    strName=doc.forms(0).elements("strName").value
  101.    MsgBox(strName)
  102.  End Sub
  103.  
  104.  Sub ie_form_loaded()
  105.    objIE.document.forms(0).elements("submit").onclick=GetRef("iesubmit")
  106.  End Sub
  107.  
  108. Class DataBaseFunctions
  109.  
  110.  ' This class is to be used client side.
  111.  
  112.  ' Declare variables to have public scope.
  113.  
  114.  Public rs
  115.  Public cn
  116.  
  117.  'Method to initialize connection to database
  118.  
  119.  Private Sub Init
  120.  
  121.   If IsObject(cn) = False Then
  122.  
  123.    Set cn = CreateObject("ADODB.Connection")
  124.    Set rs = CreateObject("ADODB.Recordset")
  125.  
  126.    cn.ConnectionString = Application("DB_CONN")
  127.    cn.Open
  128.  
  129.   End If
  130.  
  131.  End Sub
  132.  
  133.  ' Method to destory objects created.
  134.  
  135.  Public Sub Destroy
  136.  
  137.   If IsObject(rs) = True Then
  138.    rs.Close
  139.    Set rs = Nothing
  140.   End If
  141.  
  142.   If IsObject(cn) = True Then
  143.    cn.Close
  144.    Set cn = Nothing
  145.   End If
  146.  
  147.  End Sub
  148.  
  149. End Class

I haven't established a connection to the database yet, because, I have
a UI problem. If you run the above code, on line 134 I get an object required
error from WSH.

Anyone see why I'm getting the error?

v/r

Steve