Unique ID for MS Word 2007 paragraph
I am writing large MS Word 2007 documents, which开发者_运维问答 are often being changed. I have to number paragraphs with stationary unique numbers, that will not change while changing the documents. The numbers should be unique, and will not change even if previous numbers are deleted. The order of the list is not mandatory, and addition of a new number before existing numbers is possible (for instance: the sequence 1, 4, 3 means that paragraphs 1-3 were written, then #2 was deleted, then #5 was added. #3 was not affected by the later editing)
The mechanism should be internal to the document, as I am working on line and off line. The numbers are allocated to every document individually.
Since I don't know to program under MS Word, I'd appreciate getting a complete solution.
Nope, it's not possible out-of-the-box. Word does not assign a permanent index to paragraphs. The simpliest way, but it ain't so simple, to do this is to programmatically assign an index number of each Paragraph range item to a CustomXML control that wraps the paragraph on load or whenever you run it. For this or any other solution, you'll need to learn the Word object model and program it through VBA or VSTO or OpenXML.
You can wrap a paragraph in a content control (structured document tag); these can have IDs.
Iirc, Word 2010 allows paragraphs to have IDs. M$ added this because they needed it for the concurrent editing introduced in 2010.
精彩评论