Word中如何用VBA将所有图片加上边框
只要一句代码?那就给你一句参考一下吧:
picCount=ActiveDocument.InlineShapes.Count'计算文件中图片数目
在Word中,插入的图片已被转化为InlineShape对象。
之后用For循环语句,给所有图片加黑色边框。
单个图片加边框的语句,你自己可以录制一个宏看看,将录制的宏代码拷贝到For循环中修改一下即可。
有问题再补充问好了。
___________________________________________________________________
单个图片加边框,你自己录制宏就可以看到代码了,这是学习VBA的必由之路啊。
选中一张图片,工具-宏-录制新宏,然后格式-边框和阴影,给图片加上黑边框,然后alt+F11打开VB编译器,就看到代码了。本想只授人以渔即足够了,但犹豫了一下,还是贴给你吧:
WithSelection.InlineShapes(1)
With.Borders(wdBorderLeft)
.LineStyle=wdLineStyleSingle
.LineWidth=wdLineWidth050pt
.Color=wdColorAutomatic
EndWith
With.Borders(wdBorderRight)
.LineStyle=wdLineStyleSingle
.LineWidth=wdLineWidth050pt
.Color=wdColorAutomatic
EndWith
With.Borders(wdBorderTop)
.LineStyle=wdLineStyleSingle
.LineWidth=wdLineWidth050pt
.Color=wdColorAutomatic
EndWith
With.Borders(wdBorderBottom)
.LineStyle=wdLineStyleSingle
.LineWidth=wdLineWidth050pt
.Color=wdColorAutomatic
EndWith
.Borders.Shadow=False
EndWith
WithOptions
.DefaultBorderLineStyle=wdLineStyleSingle
.DefaultBorderLineWidth=wdLineWidth050pt
.DefaultBorderColor=wdColorAutomatic
EndWith
计算图片数目是为了For循环用的,有多少图片就要循环多少次,给所有图片都加上边框。
Fori=1topicCount
......
Nexti
中间就是上面那段代码,把InlineShapes(1)改为InlineShapes(i)
免责声明:本站发布的教育资讯(图片、视频和文字)以本站原创、转载和分享为主,文章观点不代表本网站立场。
如果本文侵犯了您的权益,请联系底部站长邮箱进行举报反馈,一经查实,我们将在第一时间处理,感谢您对本站的关注!
新励学网教育平台
海量全面 · 详细解读 · 快捷可靠
累积科普文章数:18,862,126篇