none
replace fields and data with formatted text in Word 2010 RRS feed

  • Question

  • I need to remove the fields and replace them with the data contents formatted appropriately throughout word 2010 documents.  Is there a way to iterate and replace the field with the text contents?  I read that in Word 2003 a Shift Ctrl F9 would do this for the selected field.  From what I have found it looks like using story to iterate would find and select.  How do I convert the fields using VB2010?

    Beginning to automate Word 2010 documents and need to be able to save documents without fields to the electronic document management system.  The fields lose the link and the data vanishes.

    Thanks,

    Steve


    Steve in California

    Monday, April 29, 2013 12:41 AM

Answers

  • Hi Steve

    Word 2010 is the same as 2003 in this respect. The Word API command is:

    [OBject].Fields.Unlink

    This will work in every document "Story". For the main document, for example: Document.Fields.Unlink (or Document.Content.Fields.Unlink) and Document.Sections(n).Headers(Word.WdHeaderFooter.wdHeaderFooterPrimary).Range.Fields.Unlink all work.

    So, yes, iterate through the Stories, get the appropriate Range and unlinking the fields shouldn't be a problem.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, April 29, 2013 6:20 AM
    Moderator