Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为ToC和ToF应用标题_C#_Ms Word - Fatal编程技术网

C# 为ToC和ToF应用标题

C# 为ToC和ToF应用标题,c#,ms-word,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 missi

我使用
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类“图表”上方设置标题?

您可以添加以下行:

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


如果我将该代码放在创建TOF之前,TOF将替换“图表”\n,如果我将其移到后面,文本将替换TOF
rangeForTOCTOF.Text=“图表\n”;TableOfFigures tof=wordDoc.TableOfFigures.Add(RangefortOtof,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失)您正在使用什么VSTO和Word版本?什么是.NET框架?SharpDevelop是工作空间,Word 10和interop.Word版本12。我使用.NET4
rangeForTOCTOF.InsertAfter("Table of Figures\n");