[英]Opening multiple hyperlinks in VBA in separate tabs
我已经找到许多解决此问题的方法,但是这是到目前为止找到的最好的代码:
Sub OpenHyperLinks()
Dim xHyperlink As Hyperlink
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each xHyperlink In WorkRng.Hyperlinks
xHyperlink.Follow
Next
End Sub
问题在于,这会在同一选项卡中打开所有超链接,因此我只会加载最后一页。 我想要的是所有显示在单独选项卡中的链接。 我该如何修改以获得所需的内容?
Welp,我终于找到了一个更好的解决方案:只需使用Wscript。
Sub OpenDemLinksBoi()
Dim SelecRng As Range
Set SelecRng = Application.Selection
Set SelecRng = Application.InputBox("Range", SelecRng, Type:=8)
For Each Cell In SelecRng
Set objShell = CreateObject("Wscript.Shell") 'I think this basically allows you to input shell commands, hence the "Run" in the next line, which functions exactly like Run. Test it out, try putting a link_
'into Run and see what happens. Same thing as this script.
objShell.Run (Cell)
Next
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.