Hi,
this is odd in that I've been using a simple browser code for years but now it suddenly started telling me I have to use 'with'...and TBH I wouldn't know where to start with that.
<code>
Private Sub Form_Load()
<Set up>
do
Go1 = "no"
Timer1.Interval = 3000 '3 seconds
Timer1.Enabled = True
WebBrowser1.Navigate2 (url)
While Go1 = "no"
DoEvents
Wend
loop, etc
end sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
DoEvents
'it errors here telling me to use 'with - end with'
xfer3 = WebBrowser1.Document.body.parentNode.innerText
If InStr(xfer3, xfer2) Then 'check for specific name
If InStr(xfer3, Date1) Then 'check start date
If InStr(xfer3, Date2) Then 'check end date
'save inner text
xfer3 = Location & "inner\" & xfer2 & " 1 InnerText.txt"
Open xfer3 For Output As #2
Print #2, WebBrowser1.Document.body.parentNode.innerText
Close #2
List1.AddItem xfer2 & " page saved "
Go1 = "yes"
DoEvents
Exit Sub 'page done, no need to re-enable the timer
End If
End If
End If
List1.AddItem "Timer"
Timer1.Interval = 1000 'one second
Timer1.Enabled = True
DoEvents
Exit Sub
</code>
the first section gets the url and starts the browser then loops until it gets a 'completed' signal, then gets the next URL.
After three seconds the timer fires and it checks to see if the page has loaded, contains the right 'name' and 'dates' and if so it saves the page.
If not then it resets the timer and fires again at one second intervals.
It now stops at the 'timer sub' line 'xfer3 = browser...innertext'.
Any idea please?
BTW, Document complete doesn't work as it fires half-a-dozen times as the page is loading...
and then fires again as the 'next' page is loading and messes up any counting I can do.
Regards
Peter
this is odd in that I've been using a simple browser code for years but now it suddenly started telling me I have to use 'with'...and TBH I wouldn't know where to start with that.
<code>
Private Sub Form_Load()
<Set up>
do
Go1 = "no"
Timer1.Interval = 3000 '3 seconds
Timer1.Enabled = True
WebBrowser1.Navigate2 (url)
While Go1 = "no"
DoEvents
Wend
loop, etc
end sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
DoEvents
'it errors here telling me to use 'with - end with'
xfer3 = WebBrowser1.Document.body.parentNode.innerText
If InStr(xfer3, xfer2) Then 'check for specific name
If InStr(xfer3, Date1) Then 'check start date
If InStr(xfer3, Date2) Then 'check end date
'save inner text
xfer3 = Location & "inner\" & xfer2 & " 1 InnerText.txt"
Open xfer3 For Output As #2
Print #2, WebBrowser1.Document.body.parentNode.innerText
Close #2
List1.AddItem xfer2 & " page saved "
Go1 = "yes"
DoEvents
Exit Sub 'page done, no need to re-enable the timer
End If
End If
End If
List1.AddItem "Timer"
Timer1.Interval = 1000 'one second
Timer1.Enabled = True
DoEvents
Exit Sub
</code>
the first section gets the url and starts the browser then loops until it gets a 'completed' signal, then gets the next URL.
After three seconds the timer fires and it checks to see if the page has loaded, contains the right 'name' and 'dates' and if so it saves the page.
If not then it resets the timer and fires again at one second intervals.
It now stops at the 'timer sub' line 'xfer3 = browser...innertext'.
Any idea please?
BTW, Document complete doesn't work as it fires half-a-dozen times as the page is loading...
and then fires again as the 'next' page is loading and messes up any counting I can do.
Regards
Peter