• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Navigation to default internet web browser's (tabs)

inddon

Member
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:

Sr.ParametersValues
1Default Web Browser:Google Chrome
2URL:www.google.com
3Web 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): 72016
.....else
...........Open the default Web Browser and the url passed "www.google.com"
......................................(Browser is opend but Tab does not exists): 72017
......................................(open a new Tab):72018
.....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
 
Back
Top