Visual Studio Developer Center >
Visual Studio Forums
>
Visual Studio Tools for Office
>
Word 2003: Process text in specific positons of a document
Word 2003: Process text in specific positons of a document
- Hello,
since I'm new to Office Programming I have an easy question to witch I have not found an answer yet.
I want to build an Office Automation solution for Word 2003 using VSTO that needs to process text the user enters at specific positions of a document.
For instance I have a table where the user has to fill values into some columns. The other columns of the table are filled by the solution I want to build.
My problem is that I do not know how to access the data the user enters and how to write into the other columns. Another requirement is that there will be different kind of data in the document (for example entries in table x of type a and entries in table y of type b).
I know that a XML schema can be mapped to an Word document, but is there a different solution for the problem since the XML-Tags can be deleted by the users (who will use the solution and will not be familiar with programming) and then the schema will be violated?
Thanks in advance for your replies,
Thomas.- Changed TypeCindy MeisterMVP, ModeratorMonday, November 02, 2009 3:29 PMit's a question
Answers
- Hi Thomas
Mmmm, difficult question, as we don't really understand a lot about your scenario. But perhaps enough to give you some general information that may get you further.
Word is not designed to be a "data gatherer". It can be used for that, with certain limitations, but protecting data and structural integrity is always a challenge. So you have to be prepared for extra work and certain limitations.
In Word 2003 there are two basic ways you can protect the data and the structure: Information Rights Management (IRM) or Forms protection with form fields. Neither of these are specific to or implemented in VSTO - they can be used in conjunction with VSTO but the Tools don't extend them in any way and in-depth discussions about using them are often best directed to a venue specializing in the Word application.
You could, for example, select the range within an XML node and designate it as editable, or insert a form field into it. (You'll find the funcitonality in the UI in the Tools/Protect Document menu, which displays a task pane.) Due to how Word manages ranges, it might be necessary to have a space character at either "end" of the XML node in order to fully protect the node. Once you've set up the document, you need to apply Protection.
Given your requirements, you might want to consider using InfoPath for data-gathering, then generate a Word document from the result.
Cindy Meister, VSTO/Word MVP- Marked As Answer byBessie ZhaoMSFT, ModeratorFriday, November 06, 2009 10:28 AM
All Replies
- To make the question more simple:
Is there another way than using XML for accessing text/data (reading and writing text/data in specific positions of the document) in a word 2003 document using VSTO? - Hi Thomas
Mmmm, difficult question, as we don't really understand a lot about your scenario. But perhaps enough to give you some general information that may get you further.
Word is not designed to be a "data gatherer". It can be used for that, with certain limitations, but protecting data and structural integrity is always a challenge. So you have to be prepared for extra work and certain limitations.
In Word 2003 there are two basic ways you can protect the data and the structure: Information Rights Management (IRM) or Forms protection with form fields. Neither of these are specific to or implemented in VSTO - they can be used in conjunction with VSTO but the Tools don't extend them in any way and in-depth discussions about using them are often best directed to a venue specializing in the Word application.
You could, for example, select the range within an XML node and designate it as editable, or insert a form field into it. (You'll find the funcitonality in the UI in the Tools/Protect Document menu, which displays a task pane.) Due to how Word manages ranges, it might be necessary to have a space character at either "end" of the XML node in order to fully protect the node. Once you've set up the document, you need to apply Protection.
Given your requirements, you might want to consider using InfoPath for data-gathering, then generate a Word document from the result.
Cindy Meister, VSTO/Word MVP- Marked As Answer byBessie ZhaoMSFT, ModeratorFriday, November 06, 2009 10:28 AM


