我需要插入封面插入Word 2016文档。 积木是一个封面,并有
InsertOptions = (int)WdDocPartInsertOptions.wdInsertPage; //= 2
到现在为止还挺好。
但VSTO只能插入这样:
buildingBlock.Insert(range);
它插入到位的范围内。
事件Application.ActiveDocument.BuildingBlockInsert
没有提高。
使用本机插入封面页(选项卡插入 - >封面页)不正确插入(并只创建一个撤销条目插积木)。
// -----------------------------------------------------------------
// try 1
var range = Application.ActiveDocument.Range();
range.Collapse(WdCollapseDirection.wdCollapseStart);
buildingBlock.Insert(range);
// result: inserting on the existing first page
// one undo entry
// event BuildingBlockInsert has not been raised
// -----------------------------------------------------------------
// try 2
//object start = 0;
//object end = 0;
//var range = Application.ActiveDocument.Range(ref start, ref end);
//buildingBlock.Insert(range);
// result: inserting on the existing first page
// one undo entry
// event BuildingBlockInsert has not been raised
// -----------------------------------------------------------------
// try 3
//var range = Application.ActiveDocument.Range();
//range.InsertParagraphBefore();
//var p = Application.ActiveDocument.Paragraphs[1];
//buildingBlock.Insert(p.Range);
// result: inserting on the existing first page
// two undo entries
// event BuildingBlockInsert has not been raised
// -----------------------------------------------------------------
类似的问题在说明中描述的: https://docs.microsoft.com/en-us/office/vba/word/concepts/working-with-word/working-with-building-blocks#inserting-a-building -嵌段成-A-文件
这似乎VSTO忽略任何插入选项,并没有办法通过插入到参数插入选项。
VSTO如何可以插入一个新的第一页积木为Word本地行动?
我使用VS 2017年的Word 2016插件,.Net框架4.6.1。