Hi Everyone
I have a little macro which opens internet explorer and finds the relevant website using data from my spreadsheet.
It works fine however the problem is that each time you run this macro it creates a new instance of IE object i.e. opens new window. There are times that you have to run it several times and you end up with say 20 IE windows.
To keep it tidy i would like to incorporate into my code a statement that would say something like this :
check if internet explorer is already opened
- if not - create a new instance and so on,
- or if it is already open use the active window and navigate to my new url from there.
Can anyone help?
-----------------------------------------------------------
Dim appIE As Object
Dim sURL As String
If Right(ActiveCell.Text, 2) = "CZ" Then sURL = " & Left(ActiveCell.Text, InStr(1, ActiveCell.Text, " ") - 3) & "-" & Left(Right(Left(ActiveCell.Text, InStr(1, ActiveCell.Text, " ") - 1), 2), 1) & "&x=10&y=7"
Set appIE = New InternetExplorer
With appIE
.Navigate sURL
Do Until appIE.ReadyState = READYSTATE_COMPLETE
Loop
.Visible = True
End With
I have a little macro which opens internet explorer and finds the relevant website using data from my spreadsheet.
It works fine however the problem is that each time you run this macro it creates a new instance of IE object i.e. opens new window. There are times that you have to run it several times and you end up with say 20 IE windows.
To keep it tidy i would like to incorporate into my code a statement that would say something like this :
check if internet explorer is already opened
- if not - create a new instance and so on,
- or if it is already open use the active window and navigate to my new url from there.
Can anyone help?
-----------------------------------------------------------
Dim appIE As Object
Dim sURL As String
If Right(ActiveCell.Text, 2) = "CZ" Then sURL = " & Left(ActiveCell.Text, InStr(1, ActiveCell.Text, " ") - 3) & "-" & Left(Right(Left(ActiveCell.Text, InStr(1, ActiveCell.Text, " ") - 1), 2), 1) & "&x=10&y=7"
Set appIE = New InternetExplorer
With appIE
.Navigate sURL
Do Until appIE.ReadyState = READYSTATE_COMPLETE
Loop
.Visible = True
End With