【问题标题】:Clicking on hyperlink in Excel is adding 25's to the hyperlink address?单击 Excel 中的超链接是否会在超链接地址中添加 25?
【发布时间】:2018-07-20 17:21:59
【问题描述】:

我正在使用 Excel for Mac 2011。插入超链接(右键单击 -> 编辑超链接)时,Excel 会将链接地址中的所有 %20 转换为空格。一个例子:

正确的页面链接格式/路径:
http://MyFictionalSite.com/nfl/query?sdql=team%20%3D%20Bears%20and%20p%3AD%20and%20DIV%20and%20p%3ARY%20%3C%20pp%3ARY%20%3C%20ppp%3ARY%20and%20season%20%3E%3D%201996

Excel 将我的超链接地址变成:
http://MyFictionalSite.com/nfl/query?sdql=team %3D Bears 和 p%3AD 和 DIV 和 p%3ARY %3C pp%3ARY %3C ppp%3ARY 和季节 %3E%3D 1996

如果我将这些链接中的任何一个直接复制并粘贴到浏览器中,它们实际上都可以正常工作。这个问题是当我单击 Excel 中的超链接时,链接会转换为:
http://MyFictionalSite.com/nfl/query?sdql=team%20%253D%20Bears%20and%20p%253AD%20and%20DIV%20and%20p%253ARY%20%253C%20pp%253ARY%20%253C%20ppp%253ARY%20and%20season%20%253E%253D%201996

为什么只有在单击 excel 超链接时才添加这些“25”?如何解决这个问题? 像这样的一列中有超过 100 个链接我需要转换。

【问题讨论】:

标签: excel


【解决方案1】:

%25 是字符串中百分比符号 (%) 的编码字符。

您可以通过将其他浏览器设置为默认浏览器来解决此问题,这样可以更好地处理它。或者,我们可以回到您最初的问题,看看我们是否可以摆脱它。

更详细的描述请参见以下页面:

https://searchmarketingcorner.wordpress.com/tag/excel-formulas/

原始问题: 我无法在我的 Excel 版本上重现您的原始问题,但我们可以验证功能是否相同。

让我们试试这个(注意你必须选择超链接才能运行,否则它什么都不做):

Sub changepath()
' Select a range or column first.
    Dim HyperLinkCount As Long
    For HyperLinkCount = 1 To Selection.Hyperlinks.Count
        Selection.Hyperlinks(HyperLinkCount).Address = Replace(Selection.Hyperlinks(HyperLinkCount).Address, " ", "%20")
        Selection.Hyperlinks(HyperLinkCount).TextToDisplay = Replace(Selection.Hyperlinks(HyperLinkCount).Address, "%20", " ")
    Next
End Sub

循环使用一个不错的 Excel 函数“Selection.Hyperlinks.Count”来遍历可能的超链接。

然后我刚刚将我认为你想要的东西翻译成给我输出的东西。

我从这个论坛页面找到了一些:

https://www.ozgrid.com/forum/forum/help-forums/excel-general/99473-vba-hyperlink-text-to-display

【讨论】:

  • 感谢您的回复。我已经尝试过我拥有的所有浏览器。您提供的宏虽然有用,但在这种情况下无济于事,因为空格不是问题。正如你所说,它是 % 编码。
  • 很高兴你明白了,我没想到 + 符号会成为其他字符被编码时的解决方案。
【解决方案2】:

也许这只适用于这个特定版本的 Excel 2011 for Mac。但是,如果您将所有“%20”或“”(空格)替换为“+”,则超链接将正常工作。

Sub changepath()
' Select a range or column first.
    Dim HyperLinkCount As Long
    For HyperLinkCount = 1 To Selection.Hyperlinks.Count
        Selection.Hyperlinks(HyperLinkCount).Address = Replace(Selection.Hyperlinks(HyperLinkCount).Address, " ", "+")
    Next
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-24
    • 1970-01-01
    • 2014-12-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    相关资源
    最近更新 更多