2

我正在尝试使用 c# 在 word 文本后面格式化 Inlineshapes。我尝试转换为抛出错误的形状。请帮助: -


Words.Word.Application wordApp = new Words.Word.Application();  // Create word apps
Words.Word.Document wordDoc = wordApp.Documents.Add(ref wordPath1, ref missing, ref missing, ref missing);   

start = wordApp.ActiveDocument.Content.End - 1;               
Words.Word.Range rg1 = wordDoc.Range(ref start, ref missing);
rg1.InsertBreak(ref pageBreak);

rg1.InsertAfter("\r");
rg1.InlineShapes.AddPicture(files[0], ref myTrue, ref missing, ref missing);        //Get Image to insert on word docs

rg1.InlineShapes[0].Height = 500;
rg1.InlineShapes[0].Width = 500;


rg1.InlineShapes[0].ConvertToShape(); //Throwing error
4

1 回答 1

3
rg1.InlineShapes[0].ConvertToShape();

仅适用于 .docx 文档。

为了获得最大的兼容性,请使用此

 Word.Shape MyPict = wordApp.ActiveDocument.Shapes.AddPicture(files[0], false, true, pointsToLeft, pointsToTop, width, height, rg1);

然后像这样设置Zorder

MyPict.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoBringInFrontOfText);
于 2014-03-11T14:53:38.180 回答