从显示“错误!”的 MS Word 字段中恢复 URL 超链接引用无效”

发布于 2024-07-22 18:11:54 字数 1096 浏览 2 评论 0原文

我有一些包含占位符 URL 的 Word 文档。 URL 类似于“http:///service.svc”。 Word 认为这些必须是有效的 URL,并且当字段更新时,将其替换为“错误!超链接引用无效”。

当我将鼠标悬停在该错误文本上时,会弹出一个工具提示,仍然显示原始文本。 有没有办法提取原文? 该文件长达 80 多页。 当然必须有一种编程方式来做到这一点?

我已经尝试过以下代码,但似乎没有找到有问题的超链接。

        For Each oHyperlink In ActiveDocument.Hyperlinks
        If IsObjectValid(oHyperlink) Then
            If Len(oHyperlink.Address) > 0 Then
                If Mid(oHyperlink.Address, 8, 5) = "<ULR>" Then
                    oHyperlink.TextToDisplay = oHyperlink.Address
                    oHyperlink.Range.Font.Color = wdColorBlue
                    oHyperlink.Range.Font.Underline = wdUnderlineSingle
                    oHyperlink.Range.Font.UnderlineColor = wdColorBlue
                End If
            End If
        End If
    Next oHyperlink

如果在上面的代码示例中删除了测试项目 IsObjectValid 的行,它将返回一个超链接,说明“对象已被删除”。 我假设这可能是损坏的(按单词)“超链接”。 如何取回我的短信?

注意:此文档已保存并关闭,因此无法使用 Ctr+z。

信息就在那里,如何获取?

I have some word documents that have place holder URL's in them. The URL's are something like "http://<URL>/service.svc". Word has figured that these have to be a valid URL and when the fields get updated, replace them with "Error! Hyperlink reference not valid".

When I mouse over that error text, word pop's up a tooltip still showing the original text. Is there some way to extract the original text? The document is over 80 pages in length. Surely there must be a programmatic way to do this?

I've tried the following code, but it does not seem to find the Hyperlinks in question.

        For Each oHyperlink In ActiveDocument.Hyperlinks
        If IsObjectValid(oHyperlink) Then
            If Len(oHyperlink.Address) > 0 Then
                If Mid(oHyperlink.Address, 8, 5) = "<ULR>" Then
                    oHyperlink.TextToDisplay = oHyperlink.Address
                    oHyperlink.Range.Font.Color = wdColorBlue
                    oHyperlink.Range.Font.Underline = wdUnderlineSingle
                    oHyperlink.Range.Font.UnderlineColor = wdColorBlue
                End If
            End If
        End If
    Next oHyperlink

If in the above code sample you remove the line which tests if the item IsObjectValid it comes back with a load of hyperlink stating "Object has been deleted". I'm assuming this could be the broken (by word) "Hyperlinks". How do I get my text back?

Note: This document has been saved and closed so Ctr+z is not an option.

The information is in there, how do I get it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

虫児飞 2024-07-29 18:11:54

您是否尝试过使用记事本打开文件并搜索http? 这对我有用。

您还可以使用“strings”之类的程序从Word 文件中获取所有文本字符串。 请参阅 http://technet.microsoft.com/en-us/sysinternals/bb897439 .aspx

Have you tried opening the file with Notepad and searching for http? This works for me.

You can also use a program like "strings" to get all of the text strings from the Word file. See http://technet.microsoft.com/en-us/sysinternals/bb897439.aspx

飘逸的'云 2024-07-29 18:11:54

怎么样:

For Each oHyperlink In ActiveDocument.Hyperlinks
    set rng = oHyperlink.Range
    rng.Collapse wdCollapseStart
    rng.text = oHyperlink.TextToDisplay
    oHyperlink.Range.Delete
Next oHyperlink

How about:

For Each oHyperlink In ActiveDocument.Hyperlinks
    set rng = oHyperlink.Range
    rng.Collapse wdCollapseStart
    rng.text = oHyperlink.TextToDisplay
    oHyperlink.Range.Delete
Next oHyperlink
神回复 2024-07-29 18:11:54

我刚刚遇到了同样的问题,并通过使用 LibreOffice 打开文档来解决该问题。

很抱歉,我在 Word 选项中找不到任何内容来打开或恢复此内容(MacOS 12 上的 Word v16.61)。

I just had the same problem and worked around the problem by opening the document with LibreOffice.

I'm sorry I could not find anything in options of Word to open or revert this (Word v16.61 on MacOS 12).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文