Microsoft Office Tutorials and References
In Depth Information
Copying Nested Field Codes as Text
'Make sure to pick up the field codes¶
rng.TextRetrievalMode.IncludeFieldCodes = True¶
FieldString = rng.Text¶
'Work through the characters in the selection, one-by-one¶
'and build the result. If a field opening or closing brace¶
'is encountered, put a brace-character in its place¶
For i = 1 To Len(FieldString)¶
CurrChar = Mid(FieldString, i, 1)¶
Select Case CurrChar¶
Case Chr(19)¶
CurrChar = "{"¶
Case Chr(21)¶
CurrChar = "}"¶
Case Else¶
End Select¶
NewString = NewString + CurrChar¶
Next i¶
'Put the result on the clipboard, so that¶
'the user can paste it where ever needed¶
Set MyData = New DataObject¶
MyData.SetText NewString¶
End Sub¶
The fields should be updated if the number is changed to reflect the change in
the text. You can do this by running the Updating All Fields macro found on
page 131 .
Copying Nested Field Codes as Text
With this procedure, you can copy a set of nested field codes and paste the field
codes as plain text, rather than the fields themselves.
Example file:
Scenario: It can be frustrating enough just to figure out
certain field codes. Now, perhaps you want to share them with
a coworker or to place one on a web page. You copy the field
code and paste it, but only the result is pasted, even though
you hit Alt+F9 to reveal the field codes!
Using this macro, exchanging complex field solutions with
colleagues, via e-mail or other methods, can be done without
having to attach Word documents.
Search JabSto ::

Custom Search