AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1636310
Accepted
Will
Will
Asked: 2021-03-27 06:36:57 +0800 CST2021-03-27 06:36:57 +0800 CST 2021-03-27 06:36:57 +0800 CST

Word 已将我的文档文本 * 移入 * 域代码。我该如何取回它?

  • 772

好的。随机问题,不知何故,word 设法将我文档的全部内容(包括引文管理器的各种域代码在内的 7500 个奇数词)移动到一个覆盖整个文档的域代码中。第一页看起来像这样。

在此处输入图像描述

如果我将该字段转换为文本,它会擦除​​所有内容,因为就单词而言,代码实际上并没有做任何事情。由于文档太大,我无法可靠地选择该字段的内容。

有没有办法把它变成普通文本?最好使用完整的嵌入式域代码?

谢谢

microsoft-word field-codes
  • 1 1 个回答
  • 46 Views

1 个回答

  • Voted
  1. Best Answer
    Charles Kenyon
    2021-03-27T07:50:36+08:002021-03-27T07:50:36+08:00

    当您选择所有内容并按 Ctrl+F9 而不是 F9 时,可能会发生这种情况。

    选项1

    您可以在错误字段的开头和结尾放置一个额外的空格,然后将这两个空格之间的所有内容复制到新文档中。然后删除错误字段并将内容复制/粘贴回来。

    选项 2

    您可以通过 Word MVP Graham Mayor's Field Code to Text 转换器运行它并返回。该页面还具有如下所示的宏。(我建议使用加载项。)在转换回来之前删除外部字段括号。您可能必须逐个字段地进行转换。使用您的文档副本执行此操作,因为您必须恢复格式。

    选项 3

    您可以将该字段设置为工作字段。在字段的QUOTE "开头加上一个,在结尾加上另一个引号"。

    Sub FieldCodeToString()
    Dim oRng as Range
    Dim Fieldstring As String
    Dim NewString As String
    Dim CurrChar As String
    Dim CurrSetting As Boolean
    Dim fcDisplay As Object
    Dim MyData As DataObject
    Dim X As  Long
    NewString = ""
    Set fcDisplay = ActiveWindow.View
    Application.ScreenUpdating = False
    CurrSetting = fcDisplay.ShowFieldCodes
    If CurrSetting <> True Then fcDisplay.ShowFieldCodes = True
    Set oRng = Selection.Range
    Fieldstring = oRng.Text
    For X = 1 To Len(Fieldstring)
    CurrChar = Mid(Fieldstring, X, 1)
    Select Case CurrChar
    Case Chr(19)
    CurrChar = "{"
    Case Chr(21)
    CurrChar = "}"
    Case Else
    End Select
    NewString = NewString + CurrChar
    Next X
    oRng.Text = NewString
    Set MyData = New DataObject
    MyData.SetText NewString
    MyData.PutInClipboard
    fcDisplay.ShowFieldCodes = CurrSetting
    End Sub 
    

    并且,要扭转这个过程:

    Sub FieldStringToCode()
    ' Based on a macro provided by Paul Edstein
    ' Converts "textual" field codes into real field codes
    ' To do the conversion, simply paste the "textual" field codes
    ' into your document, select them and run the macro.
    Dim RngFld As Range
    Dim RngTmp As Range
    Dim oFld As Field
    Dim StrTmp As String
    Dim sUpdate As String
    Dim bFldCodes As Boolean
    Const Msg1 = "Select the text to convert and try again."
    Const Msg2 = "There are no field strings in the selected range."
    Const Msg3 = "Unmatched field brace pairs in the selected range."
    Const Title1 = "Error!"
    Const Title2 = "Update fields?"
    Application.ScreenUpdating = False
    bFldCodes = ActiveDocument.ActiveWindow.View.ShowFieldCodes
    If Selection.Type <> wdSelectionNormal Then
    MsgBox Msg1, vbExclamation + vbOKOnly, Title1
    Exit Sub
    End If
    If InStr(1, Selection.Text, "{") = 0 Or InStr(1, Selection.Text, "}") = 0 Then
    MsgBox Msg2, vbCritical + vbOKOnly, Title1
    End If
    If Len(Replace(Selection.Text, "{", vbNullString)) <> Len(Replace(Selection.Text, "}", vbNullString)) Then
    MsgBox Msg3, vbCritical + vbOKOnly, Title1
    Exit Sub
    End If
    ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
    Set RngFld = Selection.Range
    With RngFld
    .End = .End + 1
    Do While InStr(1, .Text, "{") > 0
    Set RngTmp = ActiveDocument.Range(Start:=.Start + InStr(.Text, "{") - 1, End:=.Start + InStr(.Text, "}"))
    With RngTmp
    Do While Len(Replace(.Text, "{", vbNullString)) <> Len(Replace(.Text, "}", vbNullString))
    .End = .End + 1
    If .Characters.Last.Text <> "}" Then .MoveEndUntil cset:="}", Count:=Len(ActiveDocument.Range(.End, RngFld.End))
    Loop
    .Characters.First = vbNullString
    .Characters.Last = vbNullString
    StrTmp = .Text
    Set oFld = ActiveDocument.Fields.Add(Range:=RngTmp, Type:=wdFieldEmpty, Text:="", PreserveFormatting:=False)
    oFld.Code.Text = StrTmp
    End With
    Loop
    ActiveDocument.ActiveWindow.View.ShowFieldCodes = bFldCodes
    .End = .End - 1
    If bFldCodes = False Then .Fields.ToggleShowCodes
    .Select
    End With
    Application.ScreenUpdating = True
    sUpdate = MsgBox("Do you wish to update the fields?" & vbCr + vbCr & _
    "Note that if the converted fields include ASK or FILLIN fields, " & _
    "updating will force the prompt for input to those fields", vbYesNo, Title2)
    If sUpdate = vbYes Then RngFld.Fields.Update
    Set RngTmp = Nothing
    Set RngFld = Nothing
    Set oFld = Nothing
    End Sub
    
    • 1

相关问题

  • MS Word – 如何在每页的右边缘插入一列

  • 使用 Microsoft Word 保存不带 BOM 的 UTF-8 文件

  • 如何去除Word中奇怪的空格符号

  • 在word中编辑模板以删除难看的空格

  • Microsoft Word - 如何减小所有样式的文本大小

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve