欢迎来到天天文库
浏览记录
ID:50128170
大小:147.50 KB
页数:19页
时间:2020-03-04
《EXCEL VBA 实用代码收集.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、图片切换Sub显示开或关()IfActiveSheet.Shapes("Picture2").Visible=TrueThenActiveSheet.Shapes("Picture1").Visible=TrueActiveSheet.Shapes("Picture2").Visible=FalseElseActiveSheet.Shapes("Picture2").Visible=TrueActiveSheet.Shapes("Picture1").Visible=FalseEndIfEndSub当前单元格输入数字自动分解Priv
2、ateSubWorksheet_Change(ByValTargetAsRange)IfTarget.Column>1ThenExitSubIfLen(Target(1,1))>1ThenDimoJsAsObjectSetoJs=CreateObject("ScriptControl"):oJs.Language="JScript"Target(1,2).Resize(1,254).ClearContentsTarget.Resize(1,Len(Target))=Split(oJs.eval("'"&Target&"'.match
3、(/./g);"),",")EndIfEndSubword批量修改图片大小——固定长宽Subsetpicsize()'设置图片大小Dimn'图片个数OnErrorResumeNext'忽略错误Forn=1ToActiveDocument.InlineShapes.Count'InlineShapes类型图片ActiveDocument.InlineShapes(n).Height=400'设置图片高度为400pxActiveDocument.InlineShapes(n).Width=300'设置图片宽度300pxNextnForn
4、=1ToActiveDocument.Shapes.Count'Shapes类型图片ActiveDocument.Shapes(n).Height=400'设置图片高度为400pxActiveDocument.Shapes(n).Width=300'设置图片宽度300pxNextnEndSub批量修改图片大小——按比例缩放篇Subsetpicsize()'设置图片大小Dimn'图片个数DimpicwidthDimpicheightOnErrorResumeNext'忽略错误Forn=1ToActiveDocument.InlineS
5、hapes.Count'InlineShapes类型图片picheight=ActiveDocument.InlineShapes(n).Heightpicwidth=ActiveDocument.InlineShapes(n).WidthActiveDocument.InlineShapes(n).Height=picheight*1.1'设置高度为1.1倍ActiveDocument.InlineShapes(n).Width=picwidth*1.1'设置宽度为1.1倍NextnForn=1ToActiveDocument.S
6、hapes.Count'Shapes类型图片picheight=ActiveDocument.Shapes(n).Heightpicwidth=ActiveDocument.Shapes(n).WidthActiveDocument.Shapes(n).Height=picheight*1.1'设置高度为1.1倍ActiveDocument.Shapes(n).Width=picwidth*1.1'设置宽度为1.1倍NextnEndSub批量给图片加边框DimiAsIntegerFori=1ToActiveDocument.Inli
7、neShapes.CountWithActiveDocument.InlineShapes(i)With.Borders(wdBorderLeft).LineStyle=wdLineStyleSingle.LineWidth=wdLineWidth100pt.Color=wdColorAutomaticEndWithWith.Borders(wdBorderRight).LineStyle=wdLineStyleSingle.LineWidth=wdLineWidth100pt.Color=wdColorAutomaticEndWi
8、thWith.Borders(wdBorderTop).LineStyle=wdLineStyleSingle.LineWidth=wdLineWidth100pt.Color=wdColorAutomaticEndWithWith.
此文档下载收益归作者所有