PDA

View Full Version : VBA to open list of hyperlinks in non-default browser?



Lycn
07-08-2015, 01:55 PM
Hi Everyone!

I have a code (below) that opens a list of hyperlinks that I have on sheet "Tab" and my hyperlinks are in the excel sheet at cell A2, A3.. at 30 second intervals..
This code runs perfectly on my default browser (Chrome) .

I want it to do the Exact same thing on Firefox and IE without Changing my default browser.
Hence, Yes I want the same tabs/pages open on 3 different browsers. (I have my reasons for wanting/needing this).
I've been trying to find a simple way to code it, such as something like adding
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application") to the top like that.. I hope it can be simple like that, but so far it hasn't been...

Please help, thank you very much!!

thanks!!
Ly

Windows 8
Excel 2010
VBA knowledge : (very very basic/beginner)

Code below:

Sub Openlinks ()

On Error Resume Next
Sheets("Tab").Select

Range("A2").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Application.Wait (Now + TimeValue("00:00:30"))
Range("A3").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Application.Wait (Now + TimeValue("00:00:30"))

End Sub

Lycn
07-08-2015, 03:52 PM
I found a decent workaround for IE.. not firefox yet

Sub InternetExp()


On Error Resume Next


Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")



ie.Navigate Sheets("tab").Range("A2").Value


ie.Visible = True


Application.Wait (Now + TimeValue("00:00:30"))



end sub

Lycn
07-16-2015, 09:06 AM
So I found an answer / workaround to my own question for Firefox.. you have to put the link inside with 3 """ on each side. This gets the job done.


Sub Firefox()


Dim objShell


Set objShell = CreateObject("WScript.Shell")
objShell.Run ("""C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"" ""www . Hyperlink 1 .com """)
Application.Wait (Now + TimeValue("00:00:10"))


objShell.Run ("""C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"" ""www . Hyperlink2 .com""")


End Sub

Kenneth Hobs
07-16-2015, 11:02 AM
Shell() will suffice.

Lycn
07-27-2015, 11:34 PM
And for good measure.. if you want to use Opera.. :)

Sub Opera()


Dim objShell
Set objShell = CreateObject("WScript.Shell")

objShell.Run ("""C:\Program Files (x86)\Opera\launcher.exe"" ""website . com """)


End Sub