none
String RRS feed

  • Question

  • i have a string, i want that string to be fixed, editing is not possible when am creating a plugin for word, do you have any code for that?
    Tuesday, November 30, 2010 10:27 AM

Answers

  • Hi neo

    If the user should otherwise be able to edit the table, then it will not be possible for you to protect that text against deletion. Word 2002 simply does not have this capability.

    About the best you can do is something like the following, or a variation thereof:

    1. Write the string value to a document Variable object. There is no interface for the user to access document Variables (strings stored in the binary document file).

    2. Display the content of the document Variable using a DocVariable field. The user can edit the field content, but whenever it's updated, all edits will be lost.

    3. The user will be able to delete the field, as there's no way in Word 2002 to protect only part of a table. Your add-in can work with events such as DocumentBeforePrint and DocumentBeforeSave to check the content of the table cell. If it's not a DocVariable field that refers to the document Variable storing the string, delete the cell contents and reinsert the DocVariable field. If the content is the right DocVariable field, update it.

    It would be possible to use forms protection, insert a section break before and after the table, and protect the section with the table. You'd have to insert form fields in every table cell the user is allowed to edit. You then need to activate Forms protection. The drawback to this approach is that the user will not be able to use any formatting in the form fields. He will also not be able to edit the header or footer and will not be able to work with graphics in the document.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Monday, December 6, 2010 7:08 AM
    Wednesday, December 1, 2010 11:28 AM
    Moderator

All replies

  • Which version of Word is involved? That very much determines what options are open to you.

    For Word 2007 and Word 2010 you could use a content control. For earlier versions of Word, about the only option would be to create a graphics object with the text (it could be deleted, but not edited) or activate some kind of protection. But activating protection will limit available features in the application.


    Cindy Meister, VSTO/Word MVP
    Tuesday, November 30, 2010 1:32 PM
    Moderator
  • am using word 2002 and if am using protection, then what kind of protection?

     

    the fact is that am creating a plugin and the plugin is to create a table, 

    now in the table, there is a particular cell that there is a string in it and i dont want the user to delete the string that is available in the cell, so how i will do that?

    Wednesday, December 1, 2010 5:28 AM
  • Hi neo

    If the user should otherwise be able to edit the table, then it will not be possible for you to protect that text against deletion. Word 2002 simply does not have this capability.

    About the best you can do is something like the following, or a variation thereof:

    1. Write the string value to a document Variable object. There is no interface for the user to access document Variables (strings stored in the binary document file).

    2. Display the content of the document Variable using a DocVariable field. The user can edit the field content, but whenever it's updated, all edits will be lost.

    3. The user will be able to delete the field, as there's no way in Word 2002 to protect only part of a table. Your add-in can work with events such as DocumentBeforePrint and DocumentBeforeSave to check the content of the table cell. If it's not a DocVariable field that refers to the document Variable storing the string, delete the cell contents and reinsert the DocVariable field. If the content is the right DocVariable field, update it.

    It would be possible to use forms protection, insert a section break before and after the table, and protect the section with the table. You'd have to insert form fields in every table cell the user is allowed to edit. You then need to activate Forms protection. The drawback to this approach is that the user will not be able to use any formatting in the form fields. He will also not be able to edit the header or footer and will not be able to work with graphics in the document.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Monday, December 6, 2010 7:08 AM
    Wednesday, December 1, 2010 11:28 AM
    Moderator