JudahRaion
New Member
- Joined
- Oct 13, 2011
- Messages
- 20
Hi, someone know why when after 50 times doing this loop vba give me back an error "type missmatch"?
I can't figure it out.
Thank you a lot guys.
I can't figure it out.
Thank you a lot guys.
Code:
Sub observacoes()
the_start:
Dim rng As Range
clientes = Range("A10000").End(xlUp).Row
For k = 2 To clientes
'Set ie = New InternetExplorerMedium
Set ie = CreateObject("InternetExplorer.Application")
ncliente = Range("A" & k)
ie.navigate ("URL" & ncliente)
ie.Visible = False
Do
DoEvents
If Err.Number <> 0 Then
ie.Quit
Set ie = Nothing
GoTo the_start:
End If
Loop Until ie.readyState = 4
allHTML = ie.document.body.innerHTML
''observação data
If InStr(allHTML, "Responsável") > 0 Then
leng = Len("Responsável")
obsdt = Mid(allHTML, InStr(allHTML, "Responsável") + leng, Len(allHTML))
leng = Len("conteudo")
obsdt = Mid(obsdt, InStr(obsdt, "conteudo") + leng, Len(obsdt))
leng = Len("<small><font")
obsdt = Mid(obsdt, InStr(obsdt, "<small><font") + leng, Len(obsdt))
leng = Len(">")
obsdt = Mid(obsdt, InStr(obsdt, ">") + leng, Len(obsdt))
obsdt = Mid(obsdt, 1, InStr(obsdt, "<") - 1)
Dim obsdt2 As Date
obsdt2 = obsdt >>> here is where the error occurs
Rows("1:1").Select
Set rng = Selection.Find(What:="ÚLTIMA OBSER.", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
coluna = rng.Column
Cells(k, coluna) = obsdt2
Range("A" & k).Select
End If
''observação responsável
If InStr(allHTML, "Responsável") > 0 Then
leng = Len("Responsável")
obsresp = Mid(allHTML, InStr(allHTML, "Responsável") + leng, Len(allHTML))
leng = Len("conteudo")
obsresp = Mid(obsresp, InStr(obsresp, "conteudo") + leng, Len(obsresp))
leng = Len("<small><font")
obsresp = Mid(obsresp, InStr(obsresp, "<small><font") + leng, Len(obsresp))
leng = Len(">")
obsresp = Mid(obsresp, InStr(obsresp, ">") + leng, Len(obsresp))
leng = Len("<small><font")
obsresp = Mid(obsresp, InStr(obsresp, "<small><font") + leng, Len(obsresp))
leng = Len("<small><font")
obsresp = Mid(obsresp, InStr(obsresp, "<small><font") + leng, Len(obsresp))
leng = Len(">")
obsresp = Mid(obsresp, InStr(obsresp, ">") + leng, Len(obsresp))
obsresp = Mid(obsresp, 1, InStr(obsresp, "<") - 1)
Rows("1:1").Select
Set rng = Selection.Find(What:="ÚLTIMA OBSER.", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
coluna = rng.Column
Cells(k, coluna).ClearComments
Cells(k, coluna).AddComment obsresp
Range("A" & k).Select
End If
ie.Quit
Set ie = Nothing
Next k
End Sub