Maybe a long shot.
Is there a way to capture an open browser address?
Lets say I have Chrome or IE open ( not in VB6 ) is there an API to detect which browser is open and to capture the url via VB?
Capture Browser address
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Capture Browser address
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78523
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Capture Browser address
Set a reference to Microsoft Internet Controls.
The following procedure will list the URLs of all open tabs in Internet Explorer:
(Adapted from Get Current URL in IE Using Visual Basic)
I don't know how to find the active tab (the code in the above link doesn't do that, although it claims to do so), and I have no idea how to do this for Chrome, if it is possible at all.
The following procedure will list the URLs of all open tabs in Internet Explorer:
Code: Select all
Sub GetURLs()
Dim sw As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Set sw = New SHDocVw.ShellWindows
For Each objIE In sw
Debug.Print objIE.LocationURL
Next objIE
Set sw = Nothing
Set objIE = Nothing
End Sub
I don't know how to find the active tab (the code in the above link doesn't do that, although it claims to do so), and I have no idea how to do this for Chrome, if it is possible at all.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Re: Capture Browser address
Cheers Hans
A quick test gives me:
User-defined type not defined and errors on the first line of code.
I have the "Microsoft Internet Controls" active in the project references.
Any idea's?
A quick test gives me:
User-defined type not defined and errors on the first line of code.
I have the "Microsoft Internet Controls" active in the project references.
Any idea's?
Code: Select all
Private Sub Command1_Click()
GetURLs
End Sub
Sub GetURLs()
Dim sw As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Set sw = New SHDocVw.ShellWindows
For Each objIE In sw
Debug.Print objIE.LocationURL
Next objIE
Set sw = Nothing
Set objIE = Nothing
End Sub
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78523
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Capture Browser address
Are you absolutely sure? I tested the code, and it worked.
IntelliSense recognizes ShDocVw:
The reference:
ShDocVw really is part of Microsoft Internet Controls:
IntelliSense recognizes ShDocVw:
The reference:
ShDocVw really is part of Microsoft Internet Controls:
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Re: Capture Browser address
Perhaps theres different versions of the control:??
You do not have the required permissions to view the files attached to this post.
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78523
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Capture Browser address
What happens if you replace both instances of ShDocVw with ShDocVwCtl?
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Re: Capture Browser address
I get type mismatch?
You do not have the required permissions to view the files attached to this post.
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78523
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Capture Browser address
Apparently I have an entirely different library on my PC than you have. I have tried to search for a solution using ShDocVwCtl, but can't find it. Sorry.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Re: Capture Browser address
No Probs Hans.
It was always a long shot given the different browsers available so it would end up being a pointless addition to the project.
Have a great weekend. And thanks.
It was always a long shot given the different browsers available so it would end up being a pointless addition to the project.
Have a great weekend. And thanks.
Cheers ...
Dave.
Dave.