c# 向word指定位置插入图片 急急!!!

shioooyin 2009-04-02 04:45:07
这是我写的代码 但是只能在第一页 插入图片
我想要的是 在任意一页任意位置都可以插入图片

Object Nothing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application oWord;
Microsoft.Office.Interop.Word.Document oDoc;
object name = "d:\\wordFile/myfile.doc";
object Range = System.Reflection.Missing.Value;
oWord = new Microsoft.Office.Interop.Word.ApplicationClass();
oWord.Visible = false;
//打开文档
oDoc = oWord.Documents.Open(ref name, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
object a = true;
object b = true;
object left = null;
object top = null;
//定义位置
if (len == 1)
{
left = 80; top = 280;
}
if (len == 2)
{
left = 80; top = 480;
}
if (len == 3)
{
left = 80; top = 680;
}
if (len == 4)
{
left = 80; top = 880;
}
if (len == 5)
{
left = 80; top = 1080;
}
object width = 300;
object height = 150;
oDoc.Shapes.AddPicture(str, ref a, ref b, ref left, ref top, ref width, ref height, ref Nothing);
oDoc.Save();
oWord.Documents.Close(ref Nothing, ref Nothing, ref Nothing);


请大家 指教 谢谢!!!
...全文
106 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,096

社区成员

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

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

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