我正在尝试使用c#格式化文本中的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
答案 0 :(得分:2)
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);