Read all urls in ie and write to a file

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Legend
Newbie
Posts: 10
Joined: Fri Apr 04, 2014 12:11 am

Read all urls in ie and write to a file

Post by Legend » Wed Oct 15, 2014 5:12 pm

I'm tired of manually copying all the urls one by one in ie browser tab links or multiple ie windows/browsers urls address link field, then paste into a text file.

Anyone have any simple coding method of doing it?

Thank you.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Read all urls in ie and write to a file

Post by Marcus Tettmar » Tue Oct 21, 2014 3:45 pm

Can you clarify your requirements?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Legend
Newbie
Posts: 10
Joined: Fri Apr 04, 2014 12:11 am

Re: Read all urls in ie and write to a file

Post by Legend » Thu Oct 23, 2014 1:36 pm

I mean the actual link in the address bar in IE, I want to copy that link into a file.

Eg, if I open multiple IE tabs, I just want copy the address link in each IE tab into a file or
if I open multiple IE windows, I want copy the address link in each IE window into a file.

For now, I'm doing it manually copy and paste link by link into a file, so I guess whynot create a macro to do it instead.
But I have no idea how to do it.

Thanks.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Read all urls in ie and write to a file

Post by Marcus Tettmar » Thu Oct 23, 2014 1:54 pm

Try this:

Code: Select all

VBSTART
Sub GetURLS(filename)
  set objShell = CreateObject("shell.application")
  set objShellWindows = objShell.Windows

  If objShellWindows.Count = 0 Then
      WScript.Echo "Can not find any opend tabs in Internet Explorer."
  Else
      Set objFSO = CreateObject("Scripting.FileSystemObject")

      Set objExportFile = objFSO.CreateTextFile(filename, ForWriting, True)

      For Each objItem In objShellWindows
          FileFullName = objItem.FullName
          objFile = objFSO.GetFile(objItem.FullName)
          objFileName = objFSO.GetFileName(objFile)

          If LCase(objFileName) = "iexplore.exe" Then
              LocationURL = objItem.LocationURL
              'LocationName = objItem.LocationName
              objExportFile.WriteLine LocationURL
          End If
      Next
  End If
End Sub
VBEND

Let>out_file=C:\temp\IEurls.txt
DeleteFile>out_file
VBRun>GetURLs,out_file
Set the path of out_file to your preference.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

newuser
Pro Scripter
Posts: 64
Joined: Tue Jun 11, 2013 4:53 pm

Re: Read all urls in ie and write to a file

Post by newuser » Mon May 25, 2015 10:25 am

What if I want to change it to get all the urls in google chrome or firefox and write it into a file, any idea how I could do that?

Can anyone show me how its done, thank you.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Read all urls in ie and write to a file

Post by Marcus Tettmar » Tue May 26, 2015 4:07 pm

The code provided works only with IE. IE offers a very convenient API which can be used to get the data you're after and hook into the html elements. Chrome and FF not so much, at least not one we currently have access to.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts