
Sub Enel()
Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = "wdmdd.enel.it/ azienda /index_azienda .asp"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
HTMLDoc.document.all.UserName.Value = "IT001E0038"
HTMLDoc.document.all.Password.Value = "Eseio12"
For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Name = "Password" Then oHTML_Element.Click: Exit For
Next
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
|
Sub Scarica_Lista()
On Error GoTo Scarica_Err
Dim IE As Object
Dim myUtente As String, myPassword As String
Dim Giorno, Mese, Anno As Integer
Dim s_Giorno, s_Mese, s_Anno As String
'Credenziali di accesso
myUtente = "nomeutente"
myPassword = "password"
'Giorno, Mese, Anno attuale
Giorno = Day(Now()): s_Giorno = IIf(Giorno < 10, "0" & Trim(str(Giorno)), Trim(str(Giorno)))
Mese = Month(Now()): s_Mese = IIf(Mese < 10, "0" & Trim(str(Mese)), Trim(str(Mese)))
Anno = Year(Now()): s_Anno = Trim(str(Anno))
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate URL_Login
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Document.Forms(0).Item("ssousername").Value = myUtente
IE.Document.Forms(0).Item("password").Value = myPassword
IE.Document.Forms(0).submit
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Navigate URL_Download
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Navigate URL_Logout
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Application.Quit
Set IE = Nothing
Scarica_Exit:
Exit Sub
Scarica_Err:
MsgBox Err.Description
Resume Scarica_Exit
End Sub
|
