Gianna
02-27-2014, 03:09 AM
Hi, I'm Gianna and first of all SORRY FOR MY ENGLISH!
I need your help to solve a big (to me!) problem.
Monthly I need to download a huge quantity of electrical data from Enel Distribuzione page.
(there is a security problem the first time but it is safe!!!)
and I'm trying to automatically download them with a VBA macro but it doesn't work.
Please can you help me?
Gianna
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 = "https://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
I need your help to solve a big (to me!) problem.
Monthly I need to download a huge quantity of electrical data from Enel Distribuzione page.
(there is a security problem the first time but it is safe!!!)
and I'm trying to automatically download them with a VBA macro but it doesn't work.
Please can you help me?
Gianna
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 = "https://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