Reply
 
Thread Tools Display Modes
  #1   Report Post  
D Bernhardt via OfficeKB.com
 
Posts: n/a
Default 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   Report Post  
Greg
 
Posts: n/a
Default

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   Report Post  
Greg
 
Posts: n/a
Default

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   Report Post  
D Bernhardt via OfficeKB.com
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mirror Text Box [email protected] Formatting Long Documents 1 January 24th 05 08:02 PM
help, problem with text field in word 2003 Salvatore Microsoft Word Help 1 January 21st 05 04:40 PM
How do I edit text of a scanned document? Toody Microsoft Word Help 2 January 14th 05 11:38 AM
Excel worksheet in Word linked text boxes Eduardo Oliveira Page Layout 0 January 6th 05 12:23 AM
Outline Renee Hendershott Page Layout 2 December 25th 04 03:49 PM


All times are GMT +1. The time now is 11:28 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"