2013-06-03 51 views
2

我想格式化使用c#中的文字背後的文字Inlineshapes。我試圖轉換成拋出錯誤的形狀。請幫助: -我想格式化使用c中的文字背後的文字形狀#


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

什麼是錯誤拋出? – Thomas

+0

錯誤是:hresult e_fail已從調用com組件返回 – skt

+0

當我嘗試使用ConvertToShame()方法將InLineshapes轉換爲形狀對象時,會引發此問題 – skt

回答

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);