word中插入图片的问题!

lytone52 2006-04-08 12:25:51
想在word中插入图片,并希望图片保持固定的大小,用以下代码 oWordApplic.Selection.InlineShapes.AddPicture(fileName,ref missing,ref missing,ref missing);
但是插入后,图片是原先的尺寸。请问如何控制图片的大小?

...全文
966 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋晟 2006-04-08
  • 打赏
  • 举报
回复
看看http://support.microsoft.com/kb/306683
lytone52 2006-04-08
  • 打赏
  • 举报
回复
jiangsheng(蒋晟.Net[MVP]) ( ) 信誉:110 2006-04-08 13:34:00 得分: 0


改一下visible属性就可以了


------------------------------
在什么时候改?我是这样:
oWordApplic = new ApplicationClass();
oWordApplic.Visible = true;
-------------------------------
但是不能打开,也就是没出现word窗口
wfhlxl 2006-04-08
  • 打赏
  • 举报
回复
Microsoft.Office.Interop.Word.Application aa = new Microsoft.Office.Interop.Word.ApplicationClass();

aa.InchesToPoints((float)0.11);
代码蜗牛sky 2006-04-08
  • 打赏
  • 举报
回复
object filename = @"C:\Inetpub\wwwroot\TestWebApp\test.doc";//文件名
Word.Application a = new Word.ApplicationClass();//建立一个Word程序对像
object Nothing = System.Reflection.Missing.Value;//空值
Word.Document b = a.Documents.Open(ref filename,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);//建立一个Word文档对像

//其实这步就是执行了这个宏
InlineShape shape = a.Selection.InlineShapes.AddPicture(@"C:\Documents and Settings\Administrator\桌面\2003121512223366481.jpg",ref Nothing,ref Nothing,ref Nothing);

shape.Height = InchesToPoints(0.5)
shape.Width = InchesToPoints(0.5)

//Selection.InlineShapes.AddPicture FileName:= "C:\Documents and Settings\Administrator\桌面\2003121512223366481.bmp", LinkToFile:=False, SaveWithDocument:=True End Sub b.Save();//保存
b.Close(ref Nothing,ref Nothing,ref Nothing);//关闭Word文档
a.Quit(ref Nothing,ref Nothing,ref Nothing);//退出Word程序
蒋晟 2006-04-08
  • 打赏
  • 举报
回复
改一下visible属性就可以了
lytone52 2006-04-08
  • 打赏
  • 举报
回复
知道怎么用了,谢谢大侠。再问个问题,分不够再加,我如何让我生成的word文档保持为打开,就是说给用户显示。
wfhlxl 2006-04-08
  • 打赏
  • 举报
回复
pic=Selection.InlineShapes.AddPicture _
"filename"
lytone52 2006-04-08
  • 打赏
  • 举报
回复
楼上的高手能说一下c#里怎么用InchesToPoints这个方法吗?
蒋晟 2006-04-08
  • 打赏
  • 举报
回复
myShape = Selection.InlineShapes.AddPicture ......

myShape.Height = InchesToPoints(0.85)
myShape.Width = InchesToPoints(0.75)

110,545

社区成员

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

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

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