积极答复者
c# word 项目符号

问题
-
想在c#中读取word中的项目符号和编号,可是在操作时无法获得。
代码如下,
int listCount = aDoc.ListTemplates.Count;
string listStr;
for (int m = 1; m <= listCount; m++)
{
object x = m;
Word.ListTemplate listT =aDoc.ListTemplates.get_Item(ref x);Word.ListLevel listL = listT.ListLevels[1];
listStr = listL.TrailingCharacter.ToString();
MessageBox.Show(listStr);
}望高手指点!
答案
-
Hi njscy,
Welcome to the MSDN forum!
根据我的理解,我们可以用ListLevel的NumberFormat来体现项目符号。在ListLevel中只能体现编号的NumberFormat和NumberStyle——这是与项目编号相关的一些信息,可能根据这两者推测出当前使用的编号模式。
如果您需要获取项目符号和编号,可以考虑使用Range.ListFormat.ListString.
static void testExist() { object missing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application(); Document doc = app.Documents.Open(@"E:\test.doc", ReadOnly: false, Visible: false); app.Visible = true; foreach (Paragraph p in doc.Paragraphs) { MessageBox.Show(p.Range.ListFormat.ListString); } }
希望对您有所帮助!
祝,一切顺利!
yoyo
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Dummy yoyoModerator 2012年2月20日 2:07
全部回复
-
-
Hi njscy,
Welcome to the MSDN forum!
根据我的理解,我们可以用ListLevel的NumberFormat来体现项目符号。在ListLevel中只能体现编号的NumberFormat和NumberStyle——这是与项目编号相关的一些信息,可能根据这两者推测出当前使用的编号模式。
如果您需要获取项目符号和编号,可以考虑使用Range.ListFormat.ListString.
static void testExist() { object missing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application(); Document doc = app.Documents.Open(@"E:\test.doc", ReadOnly: false, Visible: false); app.Visible = true; foreach (Paragraph p in doc.Paragraphs) { MessageBox.Show(p.Range.ListFormat.ListString); } }
希望对您有所帮助!
祝,一切顺利!
yoyo
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Dummy yoyoModerator 2012年2月20日 2:07
-
Hi njscy,
我暂时把一个回复标记为答案。如果您认为该回复对您没有帮助,可以取消标记回复为答案。
谢谢您的理解!
yoyo
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us