vBulletin User ID and Password VBscript error 438

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kristina1
Newbie
Posts: 1
Joined: Thu Feb 23, 2006 2:21 am

vBulletin User ID and Password VBscript error 438

Post by kristina1 » Thu Feb 23, 2006 2:38 am

Macro Scheduler automate a login error on vBulletin User ID and Password. Can anyone help please?

VBscript error 438 line 54 "TheForm.Elements(ItemNr).Name"

Thanks in advance.

Code: Select all

VBSTART
Dim IE()
Dim MaxIEObjects

Function CreateIE
   MaxIEObjects = MaxIEObjects + 1
   ReDim preserve IE (MaxIEObjects)
   Set IE(MaxIEObjects) = CreateObject("InternetExplorer.Application")
   IE(MaxIEObjects).Visible=1
   CreateIE = MaxIEObjects
End Function

Sub Navigate(IEInst,frame,URL)
   if frame="" then
     IE(IEInst).Navigate URL
   else
     on error resume next
     dim err
     err = 0
     err = IE(IEInst).Document.Frames.length
     if err = 0 then
       IE(IEInst).Navigate URL
       exit sub
     end if
     on error goto 0
     dim frameNr
     dim frameFound
     frameFound = 0
     if IE(IEInst).Document.Frames.Length > 0 then
       for frameNr = 0 to IE(IEInst).Document.Frames.Length - 1
         if IE(IEInst).Document.Frames(frameNr).name = frame then
           IE(IEInst).Document.Frames(frameNr).navigate URL
           frameFound = 1
           exit for
         end if
       next
     end if
     if frameFound = 0 then
       IE(IEInst).Navigate URL
     end if
   end if
   do while IE(IEInst).Busy
   loop
End Sub

Sub KillIE(IEInst)
   IE(IEInst).Quit
   Set IE(IEInst) = nothing
End Sub

Sub DoForm(TheForm,fieldname,fieldvalue,submit)
   Dim ItemNr
   for ItemNr = 0 to TheForm.Elements.Length - 1
     if TheForm.Elements(ItemNr).Name = fieldname then
       TheForm.Elements(ItemNr).Value = fieldvalue
       If submit=1 then
         Dim SubItems
         Dim FoundSubmitButton
         FoundSubmitButton = 0
         for SubItems = 0 to TheForm.Elements.Length - 1
           if UCase(TheForm.Elements(SubItems).Name) = "SUBMIT" then
             if UCase(TheForm.Elements(SubItems).TYPE) = "SUBMIT" then
               TheForm.Elements(SubItems).Click
               FoundSubmitButton = 1
               Exit For
             end if
           end if
         next
         if FoundSubmitButton = 0 then
           TheForm.submit
         end if
       end if
       exit for
     end if
   next
End Sub

Sub FormFill(IEInst,frame,fieldname,fieldvalue,submit)
   Dim FormNr
   Dim TheForm
   if frame="" then
     if IE(IEInst).Document.All.Tags("FORM").Length > 0 then
       for FormNr = 0 to IE(IEInst).Document.Forms.Length - 1
         Set TheForm = IE(IEInst).Document.Forms(FormNr)
         DoForm TheForm,fieldname,fieldvalue,submit
         Set TheForm = nothing
       next
     end if
   else
     dim frameNr
     dim frameFound
     frameFound = 0
     if IE(IEInst).Document.Frames.Length > 0 then
       for frameNr = 0 to IE(IEInst).Document.Frames.Length - 1
         if IE(IEInst).Document.Frames(frameNr).name = frame then
           if IE(IEInst).Document.frames(frame).Document.All.Tags("FORM").Length > 0 then
             for FormNr = 0 to IE(IEInst).Document.frames(frame).Document.Forms.Length - 1
               Set TheForm = IE(IEInst).Document.frames(frame).Document.Forms(FormNr)
               DoForm TheForm,fieldname,fieldvalue,submit
               Set TheForm = nothing
             next
           end if
           frameFound = 1
           exit for
         end if
       next
     end if
     if frameFound = 0 then
       if IE(IEInst).Document.All.Tags("FORM").Length > 0 then
         for FormNr = 0 to IE(IEInst).Document.Forms.Length - 1
           Set TheForm = IE(IEInst).Document.Forms(FormNr)
           DoForm TheForm,fieldname,fieldvalue,submit
           Set TheForm = nothing
         next
       end if
     end if
   end if
   do while IE(IEInst).Busy
   loop
End Sub

Function ExtractTag(IEInst,TagName,Num,all)
  dim t
  set t = IE(IEInst).document.getElementsbyTagname(Tagname)
  if all=1 then
    ExtractTag = t.Item(Num).outerHTML
  else
    ExtractTag = t.Item(Num).innerText
  end if
End Function

VBEND

Let>delay=1
VBEval>CreateIE,IE[0]
VBRun>Navigate,%IE[0]%,,http://forum.XXXXX.com/usercp.php
Wait>delay
VBRun>FormFill,%IE[0]%,,vb_login_username,user,0
VBRun>FormFill,%IE[0]%,,vb_login_password,pass,0
VBRun>FormFill,%IE[0]%,,submit,,1


Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts