Processing
 

How can I add a new numbered paragraph to an existing list using Novacode?

19/09/2016 13:49#1

kkkkk

Member

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

I have an existing word document. I want read it and insert a new list item exactly after the first item of the lists.

Here is the code.

The d is a dictionary containing the numbers (the number of the list item) and the texts (the text of the list items) of the paragraphs that I want to add to the list. I can add new values to the list and see them while debugging but they don't exist in word document. They can't be saved to the word document. I couldn't find them in document.xml in the zip file (while converting docx into zip) as well.

using (var docX = DocX.Load(file))             {                 var lists = docX.Lists;                 foreach (var list in lists)                 {                     foreach (var t in d)                         {                             docX.AddListItem(list, t.Value, 0, ListItemType.Numbered, t.Key);                         }                 }                  docX.Save();             } 

I have success adding a new paragraph using the code below.

list.InsertParagraphAfterSelf() 

In this case I can have a new paragraph in my word document but I can't number it.

Similar articles

VBA regex matching over two lines

6 months ago - Reply: 1 - Views: 44

Table output to Word-2011 from Rstudio using knit

6 months ago - Reply: 0 - Views: 48

Write a Collection of paragraphs into a new document

6 months ago - Reply: 1 - Views: 72

how to write paragraphs without show to document

6 months ago - Reply: 1 - Views: 67

numericals in word macro

6 months ago - Reply: 1 - Views: 46

Can not find proofing tools

6 months ago - Reply: 0 - Views: 3

Possible values for <w:outlineLvl> in Word OOXML

6 months ago - Reply: 1 - Views: 8

C# restrict editing partial word paragraph

7 months ago - Reply: 2 - Views: 146

Macro translation Please (possible virus)

6 months ago - Reply: 1 - Views: 35

Doc/Docx Fastest Reading Method for Searching

6 months ago - Reply: 0 - Views: 3

Save embedded file / content from word

6 months ago - Reply: 0 - Views: 6

Counting words in Word document, including footnores

6 months ago - Reply: 1 - Views: 24

c# access extract word ole object

6 months ago - Reply: 1 - Views: 25

Using word wildcards to find unaccepted changes

6 months ago - Reply: 1 - Views: 46

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re