hi
i connect to a web page with this code:

Private Sub mnuCOLLEGAMENTO_Click()
Dim TheBrowser As Object, I As Integer, orario As Date
Set TheBrowser = CreateObject("InternetExplorer.Application")
With TheBrowser
.Visible = True
.Navigate ("")
End With
end Sub

then, how can i do to fill PASSWORD field and USER field?

thanks

Dani AI

Generated

Short answer: your page is a plain HTML POST form, so you must (1) wait until the page DOM is ready, (2) set the input values that match the form's NAME attributes, and (3) submit the form (preferably by clicking the submit button so any JavaScript runs). was right to use the document DOM, but if you use the wrong element names the script will silently do nothing.

Example (Internet Explorer automation — different from the snippets already posted):

Private Sub AutoLogin(userId As String, pwd As String)
  Dim ie As Object, doc As Object, elems As Object, i As Long
  Set ie = CreateObject("InternetExplorer.Application")
  ie.Visible = True
  ie.Navigate "http://www.dir*****.com"

  Do While ie.Busy Or ie.ReadyState <> 4
    DoEvents
  Loop

  Set doc = ie.Document
  If doc.getElementsByName("USER").Length > 0 Then doc.getElementsByName("USER")(0).Value = userId
  If doc.getElementsByName("PASSW").Length > 0 Then doc.getElementsByName("PASSW")(0).Value = pwd

  Set elems = doc.getElementsByTagName("input")
  For i = 0 To elems.Length - 1
    If LCase(elems(i).Type) = "submit" Then
      elems(i).Click
      Exit For
    End If
  Next
End Sub

Notes and troubleshooting:

  • Confirm exact NAME attributes with View Source or DevTools; a wrong name (for example "Username" vs "USER") is the usual cause of "nothing happens." Call Debug.Print doc.body.innerHTML while debugging to inspect the DOM.
  • Some sites require hidden fields or session cookies that are set on the initial page load. If the form has hidden inputs, include their values when doing a direct POST.
  • If the site uses client-side JavaScript to build tokens or handlers, form.submit may bypass them — prefer clicking the submit button as shown.
  • If you want a headless approach, use a proper HTTP client (WinHttpRequest or MSXML2.XMLHTTP) to POST to the form ACTION URL, but first perform any necessary GET to obtain cookies/tokens.

This should get the form filled and submitted; if it still fails, report the exact input names you see and whether the site does any JavaScript on submit so further adjustments can be suggested.

Nothing to do

here is htlm page :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 //EN">

<HTML>
<HEAD>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<TITLE> Identificazione </TITLE>
</HEAD>
<body bgcolor="#E6E0AC" text="#A6230B">
<basefont size=3 face="Times, Times New Roman">
<br><br>
<center>
<A href="http://www.directa.com" target="_blank">
<IMG src="logo.png" alt="Logo Directa" border="0"></a>
<br><br>
<BR>
<FORM ACTION="/trading/collegc_3" METHOD="POST">
<TABLE BORDER=4 ALIGN=CENTER>
<TR><TD>User : </TD>
<TD><INPUT NAME="USER" TYPE="TEXT" VALUE="" SIZE=15 MAXLENGTH="5"> </TD> </TR>
<TR><TD>Password : </TD>
<TD><INPUT NAME="PASSW" TYPE="password" VALUE="" SIZE=15 MAXLENGTH="15"> </TD> </TR>
</TABLE>
<BR>
<HR><BR>
<TABLE ALIGN=CENTER><tr><td>
<INPUT TYPE="submit" VALUE="OK">
<!--<INPUT NAME="IMG" TYPE="image" value="OK" src="/natale2.gif">-->
<input type="hidden" name=FUNZI value=HHTM>
<input type="hidden" name="xxxchg" value="x"></td></tr>
</TABLE>
</FORM>
<HR>
<br><br>
<A href="http://www.ibm.com/uk/en/" target="_blank">
<IMG src="ebim_sc.gif" alt="Logo IBM">
</a>
</center>
</BODY>
</HTML>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.