在文档的开头插入一个段落。 [英] Insert a paragraph at the beginning of the document.

查看:67
本文介绍了在文档的开头插入一个段落。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文档的开头插入一个段落。

Insert a paragraph at the beginning of the document.

Microsoft.Office.Interop.Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "-USER-";
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24;    //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();



如何添加用户名 oPara1.Range.Text = - USER - 地方。

推荐答案

您好,



您可以参考这篇文章。

使用C#创建Microsoft Word文档 [ ^ ]


你的问题让我困惑。



如果你只想在文档开头插入带有-USER-文本的段落,以下代码可能会给你一个建议。

Your question confused me.

If you just want to insert paragraph with text "-USER-" at the beginning of document, the following code may give you a suggestion.
//Insert paragraph at the beginning of document with test "-USER-"
Paragraph para = new Paragraph(document);
para.AppendText("-USER");
document.Sections[0].Paragraphs.Insert(0, para);



我使用 Word库在这个解决方案中。



如果你想要一个真实的名字,例如,蒂姆用这个TextRange-USER,我想邮件合并是最好的方法。使用字段USER创建模板,然后将值合并到此字段中。



希望有用!


I use a Word Library in this solution.

If you want to place a real name for example, Tim with this TextRange "-USER", I think mail merge is the best way. Create a template with field USER and then merge value into this field.

Hope Helpful!


这篇关于在文档的开头插入一个段落。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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