Sarvesh1993
New Member
Hi Guys,
There is a business requirement where I have to open a browser with the URL and capture the same window .I got the code for Internet Explorer and its working fine in IE but they told to do same thing in chrome/Edge . The below code is opening the window with URL and capture the window with a target URL. Could you help with the Exact code ,how can I achieve similar thing in Edge/Chrome
There is a business requirement where I have to open a browser with the URL and capture the same window .I got the code for Internet Explorer and its working fine in IE but they told to do same thing in chrome/Edge . The below code is opening the window with URL and capture the window with a target URL. Could you help with the Exact code ,how can I achieve similar thing in Edge/Chrome
Code:
Sub OpenIE(MyURL As String)
Dim objIEBrowser
Set objIEBrowser = CreateObject("InternetExplorer.Application")
objIEBrowser.Visible = True
objIEBrowser.Navigate2 MyURL
End Sub
Code:
Public Function FindIEObject(target As String)
Dim objShell
Dim IE_count
Dim X
Dim IEWindow
Dim my_url
Dim my_title
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For X = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(X).document.Location
my_title = objShell.Windows(X).document.Title
If my_url = target Then 'compare to find if the desired web page is already open
Set FindIEObject = objShell.Windows(X)
Exit For
Else
Set FindIEObject = Nothing
End If
Next
End Function