您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 用宏批量调整word中图片版式、大小、方向
Sub图片对齐()..........................................................................................................................................1Sub图片大小()..........................................................................................................................................1Sub浮于文字上方()...................................................................................................错误!未定义书签。Sub浮于文字上方()..................................................................................................................................4Sub连续()..................................................................................................................................................4Sub版式转换()..........................................................................................................................................4Sub图片方向()..........................................................................................................................................5Sub图片对齐()Application.ScreenUpdating=False'关闭屏幕更新DimnOnErrorResumeNextForn=1ToActiveDocument.Shapes.CountActiveDocument.Shapes(n).SelectSelection.ShapeRange.RelativeHorizontalPosition=_wdRelativeHorizontalPositionMarginSelection.ShapeRange.RelativeVerticalPosition=_wdRelativeVerticalPositionMarginSelection.ShapeRange.Left=wdShapeRightSelection.ShapeRange.Top=wdShapeBottomSelection.ShapeRange.LockAnchor=FalseSelection.ShapeRange.LayoutInCell=TrueSelection.ShapeRange.WrapFormat.AllowOverlap=FalseSelection.ShapeRange.WrapFormat.Side=wdWrapBothNextApplication.ScreenUpdating=True'恢复屏幕更新EndSubSub图片大小()OnErrorResumeNextDimmywidthDimmyheightApplication.ScreenUpdating=False'关闭屏幕更新mywidth=Val(InputBox(Prompt:=单位为厘米(cm);如果输入为0,则图片保持原始纵横比,宽度根据输入的高度数值自动调整;,Title:=请输入图片宽度,Default:=0))*28.35myheight=Val(InputBox(Prompt:=单位为厘米(cm);如果输入为0,则图片保持原始纵横比,高度根据输入的宽度数值自动调整;,Title:=请输入图片高度,Default:=0))*28.35'------------------------------------------------------------------'调整嵌入式图形DimpicAsInlineShapeForEachpicInActiveDocument.InlineShapesIfmywidth=0Thenpic.Height=myheightpic.ScaleWidth=pic.ScaleHeightElseIfmyheight=0Thenpic.Width=mywidthpic.ScaleHeight=pic.ScaleWidthElsepic.Width=mywidthpic.Height=myheightEndIfNext'调整浮动式图形DimtuAsShapeForEachtuInActiveDocument.ShapesIfmywidth=0Thentu.Height=myheightElseIfmyheight=0Thentu.Width=mywidthElsetu.LockAspectRatio=msoFalsetu.Width=mywidthtu.Height=myheightEndIfNextApplication.ScreenUpdating=True'恢复屏幕更新EndSubSub浮于文字上方()DimoShapeAsVariant,tuAsShape,iApplication.ScreenUpdating=False'关闭屏幕更新OnErrorResumeNext'调整嵌入图形为浮于文字上方,并旋转90度ForEachoShapeInActiveDocument.InlineShapesSetoShape=oShape.ConvertToShapeActiveDocument.InlineShapes(i).SelectWithoShape.WrapFormat.Type=3'(去除.Zorder行.WrapFormat.Type=shapeType四周形.WrapFormat.Type=wdWrapTight紧密形改为.ConvertToInlineShape嵌入形).ZOrder4'4浮于文字上方5衬于下方.Rotation=-90#EndWithNext'调整其它图形为浮于文字上方,并旋转90度ForEachtuInActiveDocument.ShapesActiveDocument.Shapes(i).SelectWithtu.WrapFormat.Type=3'(去除.Zorder行.WrapFormat.Type=shapeType四周形.WrapFormat.Type=wdWrapTight紧密形改为.ConvertToInlineShape嵌入形).ZOrder4'4浮于文字上方5衬于下方.Rotation=-90#EndWithNextApplication.ScreenUpdating=True'恢复屏幕更新EndSubSub浮于文字上方()DimoShapeAsVariant,iApplication.ScreenUpdating=False'关闭屏幕更新OnErrorResumeNextForEachoShapeInActiveDocument.InlineShapesSetoShape=oShape.ConvertToShapeActiveDocument.InlineShapes(i).Select'选中图片WithoShape.ZOrder4'选中图片版式调为浮于文字上方.Rotation=-90#'选中图片向左旋转90度EndWithNextApplication.ScreenUpdating=True'关闭屏幕更新EndSubSub连续()Call浮于文字上方Call图片大小Call图片对齐EndSubSub版式转换()DimoShapeAsVariant,shapeTypeAsWdWrapTypeOnErrorResumeNextIfMsgBox(Y将图片由嵌入式转为浮动式,N将图片由浮动式转为嵌入式,68)=6ThenshapeType=Val(InputBox(Prompt:=请输入图片版式:0=四周型,1=紧密型,&vbLf&_3=衬于文字下方,4=浮于文字上方,Default:=0))ForEachoShapeInActiveDocument.InlineShapesSetoShape=oShape.ConvertToShapeWithoShapeSelectCaseshapeTypeCase0,1.WrapFormat.Type=shapeTypeCase3.WrapFormat.Type=3.ZOrder5Case4.WrapFormat.Type=3.ZOrder4CaseElseExitSubEndSelect.WrapFormat.AllowOverlap=FalseEndWithNextElseForEachoShapeInActiveDocument.ShapesoShape.ConvertToInlineShapeNextEndIfEndSubSub图片方向()DimnOnErrorResumeNextForn=1ToActiveDocument.Shapes.CountActiveDocument.Shapes(n).IncrementRotation-90#NextnEndSub
本文标题:用宏批量调整word中图片版式、大小、方向
链接地址:https://www.777doc.com/doc-1918620 .html