我在excel中创建一个列表,从A2到A22,在此范围的每个单元格中,我都有一个超链接,我需要循环所有单元格并打开她的链接。简单的?!?!?或多或少,对我而言,比起这步更容易编写代码:
Sub PlayAllVideo()
For Each cl In Range("A2:A22")
cl.Select
Selection.Hyperlinks(1).Follow NewWindow:=True, AddHistory:=True
Next cl
End Sub
但是我的代码工作不正确,要播放所有记录,我需要一个浏览器实例,而不是同一实例中的所有选项卡。该参数NewWindow
添加一个选项卡,如果我想打开浏览器的新实例怎么办?
要避开重复使用选项卡或创建新选项卡的浏览器,只需每次创建自己的IE实例,如下所示:
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句