Solved

500 pts total cross posting question no takers yet..

Posted on 2004-10-18
6
176 Views
Last Modified: 2010-05-02
0
Comment
Question by:Informative
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 3

Author Comment

by:Informative
ID: 12351492
250 points still remain for an improvement over the ctrl-TAB ctrl-C sendkeys method to focus the address bar in explorer and copy the address to the clipboard as the best (only) means of grabbing this info programatically.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 25 total points
ID: 12354585
Hi Informative,

Not sure I understand the question 100%, but if you need to grab the URL of the Internet Explorer that has focus then here is how to do it:

Option Explicit

Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Sub Timer1_Timer()
'
'From the Project->References menu, add a reference to "Microsoft Internet Controls"
'The following code gets the current URL of the IE with focus.
'
'See also: "How To Connect to a Running Instance of Internet Explorer"
'http://support.microsoft.com/default.aspx?sd=msdn&scid=kb%3Ben-us%3B176792
'
'
    Dim shWnds As New ShellWindows
    Dim ie As InternetExplorer
    Dim lhWnd As Long
    Dim sURL As String
   
    sURL = ""
   
    'Loop all the instances of IE and see if one has focus
    For Each ie In shWnds
        'Get the handle of the window with focus
        lhWnd = GetForegroundWindow()
        'See if any IE windows have the focus
        If (ie.hWnd = lhWnd) Then
            sURL = ie.LocationURL
        End If
    Next
   
    Debug.Print sURL
   
End Sub
0
 
LVL 3

Author Comment

by:Informative
ID: 12358776
This line gives me a user defined type not defined.  
Dim shWnds As New ShellWindows

Does it perhaps require a particular library in project references?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Expert Comment

by:Erick37
ID: 12359384
Yes,

From the Project->References menu, add a reference to "Microsoft Internet Controls"
0
 
LVL 3

Author Comment

by:Informative
ID: 12359520
Yes that works!  Excellent work.
0
 
LVL 3

Author Comment

by:Informative
ID: 12359536
Please go here and post a comment so I can award you those points too Eric37

http://experts-exchange.com/Web/Web_Languages/Q_21172808.html
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question