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

fantasy_song 2010-11-12 04:22:02

这个是怎么用的,下面写法有没有错?
异常信息:用户代码未处理 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);

...全文
1228 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fantasy_song 2010-12-21
  • 打赏
  • 举报
回复
我是这样搞定的



//插入图片
object Range = System.Reflection.Missing.Value;
appWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
appWord.Selection.InlineShapes.AddPicture(HostingEnvironment.ApplicationPhysicalPath + @"Images\Logo\"+dt1.Rows[0]["dLogo"]+"", ref oMissing, ref oMissing, ref Range);
fantasy_song 2010-12-21
  • 打赏
  • 举报
回复
//插入图片
object Range = System.Reflection.Missing.Value;
appWord.Selection.ParagraphFormat.Alignment=WdParagraphAlignment.wdAlignParagraphRight;
appWord.Selection.InlineShapes.AddPicture(HostingEnvironment.ApplicationPhysicalPath + @"Images\Logo\"+dt1.Rows[0]["dLogo"]+"", ref oMissing, ref oMissing, ref Range);
fantasy_song 2010-11-15
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 q107770540 的回复:]
http://topic.csdn.net/u/20101115/08/3b6c80d6-b52c-400c-99aa-49b3b3f63982.html
[/Quote]

不是这个类,也不是这个方法
fantasy_song 2010-11-15
  • 打赏
  • 举报
回复


有没有人知道这段代码怎么用?




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




deyygywxf 2010-11-13
  • 打赏
  • 举报
回复
//bs是读出的二进制数据
byte[] bs = (byte[])read["文件"];
MemoryStream ms = new MemoryStream(bs);
Image img = Image.FromStream(ms);
cpu5182341 2010-11-13
  • 打赏
  • 举报
回复
表示关注 学习
subxli 2010-11-12
  • 打赏
  • 举报
回复
  //bs是读出的二进制数据
byte[] bs = (byte[])read["文件"];
MemoryStream ms = new MemoryStream(bs);
Image img = Image.FromStream(ms);
fantasy_song 2010-11-12
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 subxli 的回复:]
参考
[/Quote]

参考啥?那里也没有说明解决方式啊
subxli 2010-11-12
  • 打赏
  • 举报
回复
Love_Air523824 2010-11-12
  • 打赏
  • 举报
回复

110,577

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧