Word VBA-图片操作汇总
生活随笔
收集整理的這篇文章主要介紹了
Word VBA-图片操作汇总
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
==========================
Sub 圖片后加回車(chē)()Dim s As ShapeDim pg As Paragraph'先將圖片批量轉(zhuǎn)換為嵌入型For Each s In ActiveDocument.ShapesWith sIf s.Type = msoPicture Thens.ConvertToInlineShapeEnd IfEnd WithNext s'遍歷所有段落For Each pg In ActiveDocument.Paragraphs'計(jì)算段落內(nèi)的圖片數(shù)量pgCount = pg.Range.InlineShapes.CountIf pgCount > 0 ThenWith pg.Range.SelectSelection.MoveUp unit:=wdParagraph, Extend:=wdMoveSelection.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdMoveSelection.InsertAfter Chr(13)End WithEnd IfNext pgEnd Sub==========================
Sub 批量設(shè)置圖片大小()Dim n, mDim blnisinlineshape As BooleanDim mylineshape As InlineShapeOn Error Resume Next '忽略錯(cuò)誤m = ActiveDocument.InlineShapes.CountFor n = 1 To 2 'inlineshapes類(lèi)型的圖片ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '不鎖定圖片的縱橫比ActiveDocument.InlineShapes(n).Height = 153 '設(shè)置圖片高度為 243pxActiveDocument.InlineShapes(n).Width = 243 '設(shè)置圖片高度為153pxNext nFor n = 1 To 2 'inlineshapes類(lèi)型的圖片ActiveDocument.Shapes(n).LockAspectRatio = msoFalse '不鎖定圖片的縱橫比ActiveDocument.Shapes(n).Height = 153 '設(shè)置圖片高度為 153pxActiveDocument.Shapes(n).Width = 243 '設(shè)置圖片高度為243pxNext nFor n = 3 To m 'inlineshapes類(lèi)型的圖片ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '不鎖定圖片的縱橫比ActiveDocument.InlineShapes(n).Height = 297 '設(shè)置圖片高度為 297pxActiveDocument.InlineShapes(n).Width = 405 '設(shè)置圖片高度為405pxNext nFor n = 3 To m 'inlineshapes類(lèi)型的圖片ActiveDocument.Shapes(n).LockAspectRatio = msoFalse '不鎖定圖片的縱橫比ActiveDocument.Shapes(n).Height = 297 '設(shè)置圖片高度為 297pxActiveDocument.Shapes(n).Width = 405 '設(shè)置圖片高度為405pxNext nWith Selection.ParagraphFormat.LeftIndent = CentimetersToPoints(0).RightIndent = CentimetersToPoints(0).SpaceBefore = 50.SpaceBeforeAuto = False.SpaceAfter = 50.SpaceAfterAuto = False.LineSpacingRule = wdLineSpaceMultiple.LineSpacing = LinesToPoints(3).Alignment = wdAlignParagraphCenter.WidowControl = False.KeepWithNext = False.KeepTogether = False.PageBreakBefore = False.NoLineNumber = False.Hyphenation = True.FirstLineIndent = CentimetersToPoints(0).OutlineLevel = wdOutlineLevelBodyText.CharacterUnitLeftIndent = 0.CharacterUnitRightIndent = 0.CharacterUnitFirstLineIndent = 0.LineUnitBefore = 10.LineUnitAfter = 10.MirrorIndents = False.TextboxTightWrap = wdTightNone.AutoAdjustRightIndent = True.DisableLineHeightGrid = False.FarEastLineBreakControl = True.WordWrap = True.HangingPunctuation = True.HalfWidthPunctuationOnTopOfLine = False.AddSpaceBetweenFarEastAndAlpha = True.AddSpaceBetweenFarEastAndDigit = True.BaseLineAlignment = wdBaselineAlignAutoEnd WithEnd Sub==========================
==========================
==========================
==========================
==========================
==========================
==========================
==========================
==========================
==========================
?
總結(jié)
以上是生活随笔為你收集整理的Word VBA-图片操作汇总的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: xcode12 导入SwiftyJSON
- 下一篇: swpu计算机科学学院推荐免试,西南石油