none
Content of FormFields erased before printing RRS feed

  • Question

  • Private Sub Document_New()
    
    
    On Error GoTo FEHLER
    
      ActiveDocument.FormFields("planGj").Result = GetSetting(Vorlagen, InvestVorlage, "planGj", "")
      ...more code
    
      Exit Sub
    FEHLER:
      MsgBox Err.Number & " " & Err.Description
      Resume Next
    End Sub
    

    i´ve a document template with lots of fixed text and some form fields throughout the text. Creating a new document from the template should fill the form fields with data extracted from Registry Entries. This works by filling the form fields in the Document_New event handler. However if i try to print the created document, every content from the form fields is erased and not printed. I can save the document before and the content is saved within the document. However if i reopen the document and press the print button, again all content from the form fields is erased.

    Why does this happen and how can i avoid the problem?

     

    Tuesday, March 29, 2011 12:00 PM

Answers

  • Hi spille,

    Is there some document protection code in your sub? If so, you need to ensure you add the NoReset:=True parameter. For example:
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=YourPassword


    Cheers
    Paul Edstein
    [MS MVP - Word]
    • Marked as answer by spille Thursday, March 31, 2011 6:08 AM
    Wednesday, March 30, 2011 2:37 AM

All replies

  • Hi spille,

    Is there some document protection code in your sub? If so, you need to ensure you add the NoReset:=True parameter. For example:
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=YourPassword


    Cheers
    Paul Edstein
    [MS MVP - Word]
    • Marked as answer by spille Thursday, March 31, 2011 6:08 AM
    Wednesday, March 30, 2011 2:37 AM
  • Yes, this helps. Is this behaviour (erasing of Form Fields before printing if not protected) a bug or desired?
    Thursday, March 31, 2011 6:07 AM
  • Hi spille,

    My reply related to applying document protection, if that's what you're doing as part of the print process.

    If you were not protecting the document before printing, the erasure may have been caused by the 'update fields before printing' option being checked (you can check/uncheck this through code). However, that changing option affects all documents, not just the current one.


    Cheers
    Paul Edstein
    [MS MVP - Word]
    Thursday, March 31, 2011 6:48 AM