Solved

500 pts total cross posting question no takers yet..

Posted on 2004-10-18
6
173 Views
Last Modified: 2010-05-02
0
Comment
Question by:Informative
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now