我想爲段落添加樣式,但取決於單詞語言版本,我必須使用不同的名稱。現在我正在爲多個用戶創建一個應用程序,如果他們有英文版本,我可以使用「標題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();
任何想法?