Page 1 of 1

Inserting objects/paragraphs

PostPosted: Fri Jul 24, 2009 5:44 pm
by eford
The samples (much appreciated) have helped me figure out 80% of what I need for my Word document creation tasks. However, the examples tend to focus on the steps to add objects/paragraphs sequentially. I'm having some difficulty figuring out an efficient way to insert new objects/paragraphs between existing objects. Thus far, the only approach I've come up with is to iterate over the Body Block Elements and identify (using an as yet unformulated technique) the index of the object where I need to do the insert. As always, I may have overlooked an obvious solution but any suggestions would be appreciated.

Re: Inserting objects/paragraphs

PostPosted: Tue Jul 28, 2009 2:57 pm
by jason
Hi,

How were you hoping to identify your insertion point?

Something I use quite a lot is Word's content controls (w:sdt); these support an ID, which you can use. This does leave artifacts in the document which are visible to the end user in the Word 2007 interface, so if you do use this approach, you might want to remove the content controls when you are done.

cheers

Jason

Re: Inserting objects/paragraphs

PostPosted: Wed Jul 29, 2009 1:17 am
by eford
I am still trying to find a reliable method for identification. For now, luckily, the "insertion" requirement is on the back burner and most of my immediate needs are satisfied with thesequential construction approach. I am looking at the w:sdt element with regard to creating an updatable table of contents, however.

Re: Inserting objects/paragraphs

PostPosted: Sun Aug 02, 2009 9:35 am
by jason
eford wrote:I am still trying to find a reliable method for identification. For now, luckily, the "insertion" requirement is on the back burner and most of my immediate needs are satisfied with thesequential construction approach.


The other way of identifying a paragraph might be via the text (or regex) it contains.

eford wrote:I am looking at the w:sdt element with regard to creating an updatable table of contents, however.


I'll post separately re table of contents. The w:sdt is not strictly necessary.