GetViewFieldCodes代码更新: '* +++++++++++++++++++++++++++++ '* Created By ShouRou@ExcelHome 2007-5-31 12:17:04 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 00223^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit
Sub GetFiledsCodes() Dim myRange As Range, myCodes As String Set myRange = Selection.Range With myRange If .Fields.Count = 0 Then MsgBox "您所选的内容中没有域代码!", vbInformation Exit Sub Else .Fields.Update .TextRetrievalMode.IncludeFieldCodes = True .TextRetrievalMode.IncludeHiddenText = True myCodes = .Text myCodes = VBA.Replace(myCodes, Chr(19), "{") myCodes = VBA.Replace(myCodes, Chr(21), "}") .SetRange .End, .End .InsertAfter "注意,""{}""是由Ctrl+F9组合键自动插入的域标志! " & vbLf & "域代码:" & myCodes .Font.Name = "Tahoma" .Font.Size = 11 .Cut End If End With End Sub '----------------------
|