?
Solved

500 pts total cross posting question no takers yet..

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

809 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