繁体   English   中英

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

[英]Opening Selected Hyperlink DISPLAYING TEXT in Default Browser in MS Excel

我能够找到部分问题的答案,并且能够在 Excel 的一系列选定单元格中打开超链接。 但是......它只有在超链接显示并且没有被“友好文本”隐藏的情况下才有效。

当我使用下面的代码到带有超链接 (URL) 的 select 单元格时,一切都很好,它们在默认浏览器中打开。 我想要的是能够打开显示“友好文本”的超链接。 . =HYPERLINK("http://jsvp/MoveImage.aspx?t=1&sku="&A13,A4). 这会在单元格中显示“上传”一词。

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

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

即使文本隐藏了超链接(URL),是否有办法打开 URL?

感谢 PETER ALBERT ( 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

EndSub 看起来很奇怪,因为我无法在代码框中找到 go。

谢谢,莱米

这是您的代码

  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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM