VBA Access fill TextBox in Internet Explorer (1 Viewer)

MyTech

Access VBA
Local time
Today, 08:58
Joined
Jun 10, 2010
Messages
108
Can anybody please help me?

In MS Access, I'm trying to open IE, navigate to Google.com and set my text in the text box.
I don't know why it's not going.

I used:
---
Function OpenIE()
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.Navigate "http://www.google.com/"
While ie.busy
DoEvents
Wend
ie.Document.getElementById("q").Value = "My Search Text"
End Function
---


The webpage is opening but the text is not being entered. An I got an error message


Using Windows 7 - IE9 - Office 2010

I got following error:

---
Run-time error '424':
Object required
---


Using Windows Vista SP2 - IE8 - Office 2007

I got following error:

---
Run-time error '-2147467259 (80004005)':
Method 'Document' of object 'IWebBrowser2' failed
---

The error is for the last line:
" ie.Document.getElementById("q").Value = "My Search Text" "
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:58
Joined
Jan 23, 2006
Messages
15,393
I'm using Acc2003, XP sp3 , IE 6.0 ---- your code works for me.
 

the_net_2.0

Banned
Local time
Today, 07:58
Joined
Sep 6, 2010
Messages
812
are you sure the document is fully loaded by the time the code gets to that line? ie.busy is extremely unreliable. 'ie.readystate' is more reliable, but it also fails randomly. controls populate on the page last (I think). ie.busy can return false as early as the point at which the server starts sending information to the browser. in that case, the tbox population would most certainly fail.

I believe Iwebbrowser2 is part of the WinInet dll, isn't it?
 

MyTech

Access VBA
Local time
Today, 08:58
Joined
Jun 10, 2010
Messages
108
"Readystate" didn't help either.

I'm not as pro to be able to answer on the "Iwebbrowser2 is part of the WinInet dll" question.


Wondering if there's anybody able to solve the mystery ... t'would be greatly appreciated.
 

MyTech

Access VBA
Local time
Today, 08:58
Joined
Jun 10, 2010
Messages
108
Should I guess that Vista and Windows 7 are the problem???
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:58
Joined
Jan 23, 2006
Messages
15,393
Your code is working fine on

Vista Home Basic SP2
IE 8
Acc2003
 

Users who are viewing this thread

Top Bottom