Home |
Search |
Today's Posts |
|
#1
|
|||
|
|||
Vba for 'Field to plain text' [Shift][Ctrl][F9]
Hi!
Can anyone help me? How can I get hold of the VBA code for removing mergefields from a document and replacing it with plain text - Like when you use [Shift][Ctrl][F9]? And a second part to the question - can one restrict the effect of this, so that { FORMTEXT } fields are not removed? Thanks! -- Message posted via http://www.officekb.com |
#2
|
|||
|
|||
Try something like:
Sub ScratchMacro() Dim oFld As Field DocUnprotect For Each oFld In ActiveDocument.Fields If oFld.Type wdFieldFormTextInput Then oFld.Unlink End If Next oFld DocProtect End Sub Sub DocUnprotect() On Error Resume Next ActiveDocument.Unprotect End Sub Sub DocProtect() On Error Resume Next ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub |
#3
|
|||
|
|||
Try something like:
Sub ScratchMacro() Dim oFld As Field DocUnprotect For Each oFld In ActiveDocument.Fields If oFld.Type wdFieldFormTextInput Then oFld.Unlink End If Next oFld DocProtect End Sub Sub DocUnprotect() On Error Resume Next ActiveDocument.Unprotect End Sub Sub DocProtect() On Error Resume Next ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub |
#4
|
|||
|
|||
Thanks! It works fine.
I have a question about how UNLINK works. What happens if an {If else} field contains {Formtext} fields? Can one unlink the {If else} field while still keeping the contents as it is (linked)? It seems as if when unlinking an {If else} field, the field and contents are unlinked as one object. Is there a way to UNLINK the contents while keeping the fields inside? Thanks again! -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mirror Text Box | Formatting Long Documents | |||
help, problem with text field in word 2003 | Microsoft Word Help | |||
How do I edit text of a scanned document? | Microsoft Word Help | |||
Excel worksheet in Word linked text boxes | Page Layout | |||
Outline | Page Layout |