Hello There,
I am looking for a VBA code which would do the navigation/opening of a url in the default internet web browser and checing of it's Tabs.
A: The user will pass the following values:
The VBA code would do the following:
1. Check if the default web browser is open (eg. Google Chrome or Mozilla Firefox, etc. Based on the value passed.)
......If yes, then,
...........Check if there exists any open Web Browser Tab Name (User passed Tab value = "Google")
...........................If yes then activate the Web Browser Tab having name = "Google"
...................................... (Browser is open, Tab exists. Navigate to Tab):
.....else
...........Open the default Web Browser and the url passed "www.google.com"
......................................(Browser is opend but Tab does not exists):
......................................(open a new Tab):
.....end if
Below some sample VBA codes I came acroos for your reference:
Case 1:
Case 2:
Case 3:
Case 4:
Using alt+tab is going to be very messy in a macro code.
Use AppActivate title, [ wait ] instead.
Title is the text at the top of the window.
For example "Google Chrome", remember it's very picky so remember uppercase and -.
This will set focus on another application from VBA code.
https://docs.microsoft.com/en-us/of...nce/user-interface-help/appactivate-statement
Thank you and look forward to hearing from you.
Regards,
Don
I am looking for a VBA code which would do the navigation/opening of a url in the default internet web browser and checing of it's Tabs.
A: The user will pass the following values:
Sr. | Parameters | Values | |
1 | Default Web Browser | : | Google Chrome |
2 | URL | : | www.google.com |
3 | Web Browser Tab Name | : | Google (this would be used to identify the tab names) |
The VBA code would do the following:
1. Check if the default web browser is open (eg. Google Chrome or Mozilla Firefox, etc. Based on the value passed.)
......If yes, then,
...........Check if there exists any open Web Browser Tab Name (User passed Tab value = "Google")
...........................If yes then activate the Web Browser Tab having name = "Google"
...................................... (Browser is open, Tab exists. Navigate to Tab):
.....else
...........Open the default Web Browser and the url passed "www.google.com"
......................................(Browser is opend but Tab does not exists):
......................................(open a new Tab):
.....end if
Below some sample VBA codes I came acroos for your reference:
Case 1:
Code:
'https://wellsr.com/vba/2020/excel/vba-sendkeys/?utm_source=wellsrPRO&utm_campaign=592b03d329-RSS_EMAIL_CAMPAIGN&utm_medium=email&utm_term=0_5c804a55ec-592b03d329-255206257&mc_cid=592b03d329&mc_eid=636fce0e7d
Sub openURLSAutomatically()
AppActivate "Mozilla Firefox"
For i = 1 To 10
targetURL = Cells(i, 1)
SendKeys "^t"
Application.Wait Now + TimeValue("00:00:01")
SendKeys targetURL & "~"
Application.Wait Now + TimeValue("00:00:01")
Next i
End Sub
Case 2:
Code:
'https://www.mrexcel.com/board/threads/google-chrome-vba.1061569/
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url www.facebook.com")
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url www.google.com")
Case 3:
Code:
'https://www.mrexcel.com/board/threads/vba-macro-for-already-open-ie-window.553580/
Sub GetIE_LateBinding()
Dim IE As Object
With CreateObject("Shell.Application").Windows
If .Count > 0 Then
' Get IE
Set IE = .Item(0) ' or .Item(.Count - 1)
Else
' Create IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
End If
IE.Navigate "http://support.microsoft.com/kb/q176792/"
Set IE = Nothing
End With
End Sub
Case 4:
Using alt+tab is going to be very messy in a macro code.
Use AppActivate title, [ wait ] instead.
Title is the text at the top of the window.
For example "Google Chrome", remember it's very picky so remember uppercase and -.
This will set focus on another application from VBA code.
https://docs.microsoft.com/en-us/of...nce/user-interface-help/appactivate-statement
Thank you and look forward to hearing from you.
Regards,
Don