Did someone already post a tool to convert field codes to text? It is awfully tiresome not having a tool for that so I wrote one just now. Testers welcome.
A sample document containing this macro is attached. The field codes are from this thread, but it should work across a wide variety of codes of any (ha ha) complexity. If it fails, please post with comments.Code:Option Explicit Sub DocumentSelectedFieldCode() ' To aid in documenting field codes for the Lounge ' Turn a field code into text, even if nested If Selection.Fields.Count = 0 Then MsgBox "Select the field and try again." Exit Sub End If ' Call with bold Lounge markup on the braces ConvertFieldCodeToText Selection.Fields(1), True MsgBox "Done!" End Sub Sub ConvertFieldCodeToText(fld As Field, Optional blnLoungeBold As Boolean = False) ' Recursive field code converter; writes to ActiveDocument Dim intStart As Integer, strCode As String ' Keep digging until the field contains no more fields While fld.Code.Fields.Count > 0 ' This field code contains yet other field codes, so ' call myself to decode the last of them ConvertFieldCodeToText fld.Code.Fields(fld.Code.Fields.Count), blnLoungeBold Wend ' Now we have no internal fields, capture the position and ' field code contents, delete the field, and insert the plain text intStart = fld.Code.Start - 1 If blnLoungeBold Then strCode = "[b]{[/b]" & fld.Code.Text & "[b]}[/b]" Else strCode = "{" & fld.Code.Text & "}" End If fld.Delete ActiveDocument.Range(Start:=intStart, End:=intStart).InsertAfter strCode ' Clean up objects and return to calling routine If Not fld Is Nothing Then Set fld = Nothing End Sub




