C#写入图片到word------------Shapes.AddPicture

fantasy_song fantasy_song 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

这个是怎么用的,下面写法有没有错?
异常信息:用户代码未处理 System.Runtime.InteropServices.COMException
HelpLink="C:\\Program Files\\Microsoft Office\\OFFICE11\\2052\\wdmain11.chm#25332"
Message="要求的对象不可用。"
Source="Microsoft Word"
ErrorCode=-2146822436
StackTrace:
在 Microsoft.Office.Interop.Word.Shapes.AddPicture(String FileName, Object& LinkToFile, Object& SaveWithDocument, Object& Left, Object& Top, Object& Width, Object& Height, Object& Anchor)
在 MSOffice.NSWord.WordDocuments.AppendTableYouteSonghuodanTou(Int32 numRows, Int32 numColumns, WordTableFormat format, Int32 type, String billNumbers, DataTable dt) 位置 D:\客户\CRM_V1.root\CRM_V1\OfficeNS\Word\WordDocumentsYoute.cs:行号 169
在 MSOffice.NSWord.WordDocuments.CreateWordSonghuodan(DataTable dt1, String billNumbers, String songhuodanJine, DataTable dt) 位置 D:\客户\CRM_V1.root\CRM_V1\OfficeNS\Word\WordDocumentsYoute.cs:行号 384
在 Factory_SellingList.gvDistributions_RowCommand(Object sender, GridViewCommandEventArgs e) 位置 d:\客户\CRM_V1.root\CRM_V1\WebSites\Factory\SellingList.aspx.cs:行号 378
在 System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e)
在 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
在 System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e)
在 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
在 System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e)
在 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
在 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
在 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:


是什么???

求高人现身





Microsoft.Office.Interop.Word.Application oDoc = new Microsoft.Office.Interop.Word.Application();
object LinkToFile = false;
object SaveWithDocument = true;
object Left = 50;//插入点相对距离
object Top = 50;//插入点相对距离
object Width = 86;//图片宽
object Height = 85;//图片高
object tmp1 = null;
string fileName = @"../Images/youte.bmp";
oDoc.Application.ActiveDocument.Shapes.AddPicture(fileName,ref LinkToFile,ref SaveWithDocument, ref Left, ref Top, ref Width, ref Height, ref tmp1);

...全文

相关推荐

评论 13
收藏 已收藏
分享
返回顶部
fantasy_song
C# 111,128 成员 642,536 内容