Table of Content for Microsoft.interop.word.dll
本文关键字:interop word dll Microsoft for of Content Table | 更新日期: 2023-09-27 18:21:13
我已经为C#应用程序生成的word文档创建了内容表,它可以很好地进行
Range myRange = aDoc.Range(ref missing, ref missing);
object oStyleName = "Heading 1";
myRange.set_Style(ref oStyleName);
object start = wordApp.ActiveDocument.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);
toc.Update();
Range rngTOC = toc.Range;
rngTOC.Font.Size = 10;
rngTOC.Font.Name = "Georgia";
但问题是,当我点击内容时,它不会导航到特定的部分。。有人能帮我解决这个问题吗
请找到以下更新代码:
Range myRange = aDoc.Range(ref missing, ref missing);
object oStyleName = "Heading 1";
object oTrueValue = true;
myRange.set_Style(ref oStyleName);
object start = wordApp.ActiveDocument.Content.End - 1;
Range rangeForTOC = aDoc.Range(ref start, ref missing);
TableOfContents toc = aDoc.TablesOfContents.Add(rangeForTOC,
ref oTrueValue, ref missing, ref missing,
ref missing, ref missing, ref oTrueValue,
ref oTrueValue, ref oTrueValue, ref oTrueValue,
ref oTrueValue, ref oTrueValue);
toc.Update();
Range rngTOC = toc.Range;
rngTOC.Font.Size = 10;
rngTOC.Font.Name = "Georgia";
您需要包含真值对象(varTrueValue),并在创建TableOfContents时使用它。
快乐编码:)