从Windows窗体的段落之间插入到Word模板中 [英] inserting between paragraphs from windows form into word template

查看:82
本文介绍了从Windows窗体的段落之间插入到Word模板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试从vb.net自动化单词.我有一个Windows窗体,该窗体具有某些值,需要在单词模板的某些加书签的地方插入这些值.我可以正常插入,但基于某些条件子句需要在段落标题下的文档中插入. /> 我在模板中将7.6子句标记为ip_clauses.现在,基于列表框中的选择数量,将段落插入7.6(即如果选择了3,则应分别为7.7、7.8、7.9),并且现在7.7应该变成7.10.我正在使用下面的代码.

Hi,
I am trying to automate word from vb.net. I have a windows form which has certain values which need to be inserted at certain bookmarked places of a word template.I am doing fine with the normal insertions but basing on certain condition clauses need to be inserted in the document under paragraphed headings.
I have bookmarked the clause say 7.6 as the ip_clauses in the template.Now basing on the number of selection being made in the list box am inserting the paragraphs under 7.6 ( i.e if 3 are selected they should be 7.7,7.8,7.9) and the now 7.7 should become 7.10.I am using the code below.

Dim strBookMValue As String = String.Empty
        Dim wordPara As Microsoft.Office.Interop.Word.Paragraph
'looping through the list items
        For i = 0 To frmSum.lstIP.Items.Count - 1
            strBookMValue = frmSum.lstIP.Items(i) 
            wordPara = wordDocument.Content.Paragraphs.Add(wordDocument.Bookmarks.Item("ip_clauses").Range)
            wordPara.Range.Text = strBookMValue
            'wordPara.Range.InsertParagraphAfter()

        Next


我的问题是插入了段落,但覆盖了第7.6节.
另外,如果我需要在低于该条款的列表级别插入,该怎么办?
在3.4 a,b,c下说.我需要在3.4 d处添加一些内容.

任何帮助将不胜感激.


My problem is the paragraphs are inserted but are over writing the clause 7.6.
Also if i need to insert at list level lower than the clause what should I do?
say under 3.4 a ,b,c .I need to add something at 3.4 d.

Any help would be greatly appreciated.

推荐答案

如果书签用于查找要开始插入段落的位置,则应使用InsertParagraphAfter方法作为书签对象.
请阅读更多关于书签对象.
If the bookmark is using to find a place where you want to start inserting paragraphs, you should use InsertParagraphAfter method for bookmark object.
Please, read more about bookmark object.


这篇关于从Windows窗体的段落之间插入到Word模板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆