在MS Excel的默认浏览器中打开所选超链接显示文本



我找到了部分问题的答案,并能够在Excel中的一系列选定单元格中打开超链接。但是。。。只有当超链接显示而不是被"隐藏"时,它才起作用;友好文本";。

当我使用下面的代码选择带有超链接(URL(的单元格时,一切都很好,它们在默认浏览器中打开。我想要的是能够打开超链接;友好文本";。CCD_ 1这表示单词";上传";在细胞中。

=IF(LEN(A3)>5,"",HYPERLINK("https://supercms.company.com/ManageProducts/"&LEFT(A3,5),A3))显示单元格A3中的值。

我收到运行时错误"-2147221014(800401ea("无法打开指定的文件。

即使文本隐藏了超链接(URL(,也会有打开URL的方法吗?

致谢:彼得·阿尔伯特(https://stackoverflow.com/users/1867581/peter-albert?tab=profile)他的密码。

Sub Open_SelectedTextlinks()
Dim c As Range
If Not TypeOf Selection Is Range Then Exit Sub
For Each c In Selection.Cells
If c.Hyperlinks.Count = 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=c, _
Address:="http://" & c.Value 'Depending on the content of your cell, remove the "http://" & part
End If
c.Hyperlinks(1).Follow
Next
End Sub

这是您的代码

Sub Open_SelectedTextlinks()
If Not TypeOf Selection Is Range Then Exit Sub
For Each c In Selection.Cells
If c.Hyperlinks.Count = 0 Then
With Worksheets(1)
.Hyperlinks.Add Anchor:=.Range("a5"), _
Address:="https://example.microsoft.com", _
ScreenTip:="Microsoft Web Site", _
TextToDisplay:="Microsoft"
Range("A5").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End With
End If
Next
End Sub

最新更新