我想为段落添加样式,但取决于单词语言版本,我必须使用不同的名称。现在我正在为多个用户创建一个应用程序,如果他们有英文版本,我可以使用“标题1”,但是如果他们没有识别风格。我想知道我该怎么做,我应该添加一个新的风格?我一直在研究这个,但我无法弄清楚。c#Interop Word Document添加样式
所以在我的荷兰语版本使用:
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();
任何想法?