activating browser window from access

  • Thread starter Thread starter Susan
  • Start date Start date
S

Susan

I am trying to use appactivate from Access 2000 to select
an already open browser window. Perhaps the problem is
that I don't know the correct handle to refer to the
browser window. I can open the browser from Access but
the user needs to be able to find the correct page after
signing in and the position cursor on the correct field.
At that point the users returns to access and I use send
keys to send to data from access to the browser form.
But I can't get it to recognize the browser window.
Thanks in advance
 
Here's a VB code snippet used to find IE or Shell windows

Declarations

Private Declare Function GetForegroundWindow Lib "user32" () As Long
Public WithEvents myWB As WebBrowser


Dim hwnd As Long
hwnd = GetForegroundWindow()
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer

Set myWB = Nothing

For Each IE In SWs
If IE.hwnd = hwnd Then
Set myWB = IE
End If
Next

Rather than use GetForegroundWindow you could loop through the Internet
Explorer collection testing for the Location or Title of the IE Window you
want. If not found then you create a new IE instance and navigate to the
page you want and set your WB object.
Once you have your WB object, you can then get its document object and use
document methods to write to fields in the document instead of sendkeys (if
you like).
 
Back
Top