Activate a specified Firefox browser tab that is already open

MannStewart

New Member
Joined
Oct 5, 2019
Messages
14
Hi

I have an existing code as follows that opens a new Firefox browser tab each time it's run, but it ends up opening too many repeated identical tabs on the browser.

I'm thinking it should be modified to just activate the already opened tab if that URL is already open, instead of needlessly opening a new tab of the same site every time. But I don't know how to with my limited VBA knowledge, so hoping if someone could kindly help me to.

VBA Code:
Sub OpenFireFoxNewTab(url As String)

    Dim pathFireFox As String
    pathFireFox = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
    If Dir(pathFireFox) = "" Then
     pathFireFox = "C:\Program Files\Mozilla Firefox\firefox.exe"
    End If
   
    Shell """" & pathFireFox & """" & " -new-tab " & url, vbHide
  
End Sub

This is the tab opener code:
VBA Code:
Sub FireFox_TopUniv()

    OpenFireFoxNewTab "https://www.topuniversities.com/university-rankings/world-university-rankings/2024"
    
End Sub


Stewart
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
AFAIK, Firefox does not provide a COM object that allows you to interact with VBA. That's why people generally use IE for this instead. Otherwise, you're stuck with using hacks such as API's to get cursor positions and control the mouse, or SendKeys, neither of which is very reliable.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top