【发布时间】:2012-03-11 20:44:01
【问题描述】:
我想为段落添加样式,但根据单词语言版本,我必须使用不同的名称。现在我正在为多个用户创建一个应用程序,如果他们有英文版本,我可以使用“Header 1”,但如果他们没有,则无法识别样式。我想知道我应该怎么做,我应该添加一个新样式吗?我一直在研究这个,但我不知道怎么做。
所以在我使用的荷兰语版本中:
selection.TypeParagraph();
object kop1 = "Kop1";
selection.set_Style(kop1);
selection.TypeText("test");
但我需要英语:
selection.TypeParagraph();
object kop1 = "Header 1";
selection.set_Style(kop1);
selection.TypeText("test");
我实际上需要这个来创建一个内容表,如果我不使用样式,我就无法创建一个内容表,对吧?否则我的内容表会说它没有内容。
我使用以下方法制作内容表:
object start = adoc.Content.End - 1;
Range rangeForTOC = adoc.Range(ref start, ref missing);
TableOfContents toc = adoc.TablesOfContents.Add(rangeForTOC, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
adoc.TablesOfContents[1].TabLeader = WdTabLeader.wdTabLeaderDots;
adoc.TablesOfContents.Format = WdTocFormat.wdTOCClassic;
toc.Update();
有什么想法吗?
【问题讨论】:
标签: c# ms-word styles interop paragraph