First, I have write a FUNCTION(a) with only one mission , open specific webpage, it's worked! This FUNCTION(a) was add into a SUB. Here alright too. I have write a FUNCTION(b) for grab information from specific webpage, nonetheless the FUNCTION(b) shows ERROR as if the webpage not exist, even though open for FUNCTION(a). What I have include to FUNCTION(b) be linked at webpage??
VBA Code:
"FUNCTION(a)"
Function acessarweb(nomesite As String, Optional varie As String = "ie", _
Optional visivel As Boolean = True)
Set ie = CreateObject("internetexplorer.application")
ie.navigate nomesite
If visivel = True Then
ie.Visible = True
Else
ie.Visible = False
End If
Do While ie.busy And ie.readystate <> "READYSTATE_COMPLETE"
DoEvents
Loop
End Function
'-------------------------------------------------------------------------
"FUNCTION(b)"
Function raspar(tagp As String)
Dim tagprincipal As Object
Set ie = CreateObject("internetexplorer.application")
Set tagprincipal = ie.document.getelementsbytagname(tagp) <<< ERROR this line "iwebbrowser2" fail
...
do stuff
loop
for each
etc
...
End Function
'-------------------------------------------
Sub click()
acessarweb "https://br.investing.com/economic-calendar/", True
Function raspar ....
End Sub