VSTO: Issue with adding text to a list item in a list in MS Word doc using C# -
VSTO: Issue with adding text to a list item in a list in MS Word doc using C# -
original list in ms word 2010 doc:
a b c d ethe code add together text "test" end of item 2 (with value b) in list:
word.application oapp = new word.application(); word.document odoc = oapp.documents.open(filename: @"c:\folder1\test1.docx"); string st = odoc.lists[1].listparagraphs[1].range.text; odoc.lists[1].listparagraphs[2].range.text = st + "test"; ((word._document)odoc).close(savechanges: word.wdsaveoptions.wdsavechanges); ((word._application)oapp).quit(); resulting list:
a a testc d ewhat wanted:
a btest c d enotice in resulting list code doing 2 things wrong: 1. replacing sec item value b , 2. adding text "test" @ origin of item value c.
c# ms-word ms-office vsto office-interop
Comments
Post a Comment