Reputation: 662
I create one list in excel From A2 to A22, in each cell of this range I've one Hyperlink, and I need to loop all cell and open her link. Simple?!?!? more or less, for me is to easy wrote the code than this tread:
Sub PlayAllVideo()
For Each cl In Range("A2:A22")
cl.Select
Selection.Hyperlinks(1).Follow NewWindow:=True, AddHistory:=True
Next cl
End Sub
But my code work wrong, for play all record I need one instance of Browser, not all tab in the same instance.
the parameter NewWindow
add one tab, if I want open a new instance of browser how I can to do?
Upvotes: 1
Views: 3767
Reputation: 2892
To get around browsers that reuse tabs or create new tabs, simply create your own instance of IE each time like this:
Sub PlayAllVideo()
Dim IE As Object
For Each cl In Range("A2:A22")
Set IE = CreateObject("InternetExplorer.Application")
'It is generally advisable to avoid using Select and ActiveCell
'cl.Select
IE.Visible = True
IE.Navigate cl.Hyperlinks.item(1).Address
Next cl
Set IE = Nothing
End Sub
Upvotes: 1
Reputation: 882
The issue might be on the browser side. I tried using Firefox and Internet Explorer and the issue was resolved after changing browser settings. However, the solution isn't perfect as it always opens new windows regardless of the NewWindow setting in VBA.
Assuming you are using Firefox, i encountered the same behavior till I turned off the "Open new windows in a new tab instead" option. Afterwards, each hyperlink was opened in a separate window.
For Internet Explorer, under internet Options > Tabs Settings > Open Links From Other Programs was changed to A New Window instead of a New Tab.
Upvotes: 0