在单独的选项卡中打开 VBA 中的多个超链接
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
问题是这会打开同一个选项卡中的所有超链接,因此我只能加载最后一页。我想要的是在单独的选项卡中显示的所有链接。我怎样才能修改它以获得我正在寻找的东西?
好吧,我终于找到了更好的解决方案:使用 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
针对这个问题,我找到了许多不同的解决方案,但这是迄今为止我找到的最好的代码:
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
问题是这会打开同一个选项卡中的所有超链接,因此我只能加载最后一页。我想要的是在单独的选项卡中显示的所有链接。我怎样才能修改它以获得我正在寻找的东西?
好吧,我终于找到了更好的解决方案:使用 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