Below code provides information on websites that is
currently opened in user computer machine.
How to start?
1. Copy the below code
2. Open the workbook in which you want to add the code
3. Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
4. Choose Insert | Module
5. Where the cursor is flashing, choose Edit | Paste
Required Reference :
1. Choose Tools | References
2. Check Microsoft Internet Controls and click OK (See image below)
To View Immediate Window
Choose View| Immediate Window
How to run the code?
1. On the Excel Ribbon, click the View tab
2. At the far right, click Macros
3. Select a macro in the list, and click the Run button
4. Got VB Screen and See the Immediate window for results
Code:
'\\Requires reference to Microsoft Internet Controls
Dim SWs As SHDocVw.ShellWindows, vIE As SHDocVw.InternetExplorer
'\\Track website used
'\\Establish link to IE application
Sub Track_Website()
Set SWs = New SHDocVw.ShellWindows
For Each vIE In SWs
'\\Avoid explorer windows/etc this way
If Left(vIE.LocationURL, 4) = "http" Then
'\\Watch Immediate window
Debug.Print vIE.LocationURL
End If
Next
End Sub
Dim SWs As SHDocVw.ShellWindows, vIE As SHDocVw.InternetExplorer
'\\Track website used
'\\Establish link to IE application
Sub Track_Website()
Set SWs = New SHDocVw.ShellWindows
For Each vIE In SWs
'\\Avoid explorer windows/etc this way
If Left(vIE.LocationURL, 4) = "http" Then
'\\Watch Immediate window
Debug.Print vIE.LocationURL
End If
Next
End Sub
No comments:
Post a Comment