?
Solved

500 pts total cross posting question no takers yet..

Posted on 2004-10-18
6
Medium Priority
?
182 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

764 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