将标题应用于ToC和ToF

时间:2014-01-30 08:09:35

标签: c# ms-word

我使用Interop.Word以编程方式为Word文档创建图表和目录表。

//Range where ToF will be located  
Range rangeForTOCTOF = wordDoc.Range(0, 0);    

//Create ToF  
TableOfFigures tof = wordDoc.TablesOfFigures.Add(rangeForTOCTOF, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);  

wordDoc.TablesOfFigures[1].TabLeader = WdTabLeader.wdTabLeaderDots;
wordDoc.TablesOfFigures.Format = WdTofFormat.wdTOFFormal;
tof.Update();  

如何设置ToF之上的标题,如“数字表”?

1 个答案:

答案 0 :(得分:0)

您可以添加以下这一行:

rangeForTOCTOF.InsertBefore("Table of Figures\n");

或:

rangeForTOCTOF.InsertAfter("Table of Figures\n");