Home > Software engineering >  In the word automatically adjust the picture size and add black frame line
In the word automatically adjust the picture size and add black frame line

Time:09-23

1. The application of
Word writing process sometimes need to modify pictures batch size format unification, to modify the time-consuming to each picture, write a small program bulk changes hope of people often need to write a word help,
2. Program
2.1 image resizing
'Sub image format adjustment ()
'
'image format to adjust macro
Dim number n 'picture

On the Error Resume Next 'ignore Error

For n=1 To ActiveDocument. InlineShapes. Count 'InlineShapes type image

ActiveDocument. InlineShapes (n.) LockAspectRatio=msoFalse 'not lock aspect ratio, important, or it will deformation
ActiveDocument. InlineShapes (n). Height=6.73 * 28.35 'set the picture Height is 260 px, 1 cm=28.35

ActiveDocument. InlineShapes (n.) Width=14.57 * 28.35 'set image Width 413 px

ActiveDocument. InlineShapes (n). Range. ParagraphFormat.=wdAlignParagraphCenter 'Alignment image center

The Next n

'For n=1 To ActiveDocument. Shapes. The Count' S hapes type picture
'
'ActiveDocument. Shapes (n). Height=400' set the picture Height is 400 px
'
'ActiveDocument. Shapes (n.) Width=413' set image Width 300 px
'
'ActiveDocument. InlineShapes (n). Range. ParagraphFormat.=wdAlignParagraphCenter' Alignment image center
'
'the Next n
End Sub increase to the picture frame
2.2 pictures add black border
Sub increase picture frame ()
'add picture frame macro
Dim oInlineShape As InlineShape
Application. ScreenUpdating=False
For Each oInlineShape In ActiveDocument. InlineShapes
With oInlineShape. Borders
. OutsideLineStyle=wdLineStyleSingle
. OutsideColorIndex=wdColorAutomatic
. OutsideLineWidth=wdLineWidth050pt
End With
Next
Application. ScreenUpdating=True
End Sub

CodePudding user response:

Start recording macros in the Word2003, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,
  •  Tags:  
  • VBA
  • Related