Error 3265 calling IE from VBA
I'm using IE to publish my report from Excel, but sometimes - not consistently, but frequently - it reports error 3265 (Item not found in this collection). I can continue through the error and the report is generated perfectly. I have used an 'on error resume next' which allows the user to close IE and generate the report again, but why is it doing this? How do I prevent it? Code is as follows:
Set IE = New InternetExplorer
With IE
.FullScreen = False
.MenuBar = False
.Offline = True
.Resizable = True
.StatusBar = False
.Visible = True
.Toolbar = True
.Width = lngScreenWidth
.Height = lngScreenHeight
.Navigate ("about:blank")
.Document.body.innerhtml = strHtmlTop & arrPage & strHtmlBottom
End With
Set IE = Nothing
Thank you for your assistance.
[898 byte] By [
rod_weston] at [2007-11-11 8:51:01]

# 2 Re: Error 3265 calling IE from VBA
Is that possible?! You mean I have to slow down even further to make this work? I'll try it, but I don't like the idea of moving slower than I must. Thanks for the idea, though.
# 3 Re: Error 3265 calling IE from VBA
Purely for test purposes i'd to the following.
In a public module, declare:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Then in your routine:
Set IE = New InternetExplorer
With IE
.FullScreen = False
.MenuBar = False
.Offline = True
.Resizable = True
.StatusBar = False
.Visible = True
.Toolbar = True
.Width = lngScreenWidth
.Height = lngScreenHeight
sleep(100) 100 milliseconds or 1/10th of a second
.Navigate ("about:blank")
sleep(100)
.Document.body.innerhtml = strHtmlTop & arrPage & strHtmlBottom
sleep(100)
End With
Set IE = Nothing
If it's completely stable with the sleeps in, you can go from there. If it's still tempromental, then it's some other issue.
# 6 Re: Error 3265 calling IE from VBA
Oh, I forgot to say - you could use DoEvents.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctdoevents.asp