Batch set image size in Word

Source: Internet
Author: User
Document directory
  • Method 1:
  • Method 2:
Batch modify image size in word -- fixed length and width Article Method 1:

In this part, we need to change all the images in word to a fixed length and width!
1. Open the word tool-macro-Macro (or press Alt + F8) to enter the macro
Interface, as shown below, enter a macro name and start with the macro name. Just remember it!

2. Click Create to enter the Visual Basic Editor. Enter the following code and save it.
Sub

Setpicsize () 'sets the image size


Dim
N

'
Number of images
On Error Resume Next'
Ignore errors





For
N = 1

ActiveDocument. InlineShapes. Count 'inlineshapes
Type Image

ActiveDocument. InlineShapes (n). Height = 400 'set the Image Height to 400px


ActiveDocument. InlineShapes (n). Width = 300 'set the image Width to 300px.

Next
N

For
N
= 1

ActiveDocument. Shapes. Count 'shapes
Type Image

Activedocument. shapes (N). Height = 400 'set the Image Height to 400px


Activedocument. shapes (N). width = 300 'set the image width to 300px

Next
N
End sub

3. Return to the word, the tool-macro-Macro (or press Alt + F8), enter the macro page again, select the macro you just edited, and click the "run" button, that's it! (When there are many images,
It may take some time)

 

Method 2:

1. press Alt + F11 in word to enter the VBA mode
2. Find your word document in the project resource manager on the left and right-click it/Add/Module
3. copy and paste the following code.
4. Change the value, set the width and height (10), and click Run (similar to the playback button) or F5 to set all the images in the document.

Sub macro ()
Mywidth = 10'10 indicates the image width (cm)
Myheigth = 10' 10 indicates the Image Height (cm)
For each ishape in activedocument. inlineshapes
Ishape. Height = 28.345 * myheigth
Ishape. width = 28.345 * mywidth
Next ishape
End sub

 

Batch modify image size in word-proportional Scaling

This part is to scale all the images in Word proportionally!
The specific operation is the same as above, but the code is slightly modified. The Code is as follows:
Sub

Setpicsize () 'sets the image size


Dim
N

'Number of images



Dim
Picwidth
Dim
Picheight
On Error resume next 'ignore Error




For

N = 1
Activedocument. inlineshapes. Count 'inlineshapes
Type Image

Picheight = activedocument. inlineshapes (N). Height
Picwidth
= Activedocument. inlineshapes (N). Width
Activedocument. inlineshapes (N). Height
= Picheight * 1.1 ': Set the height to 1.1 times.

Activedocument. inlineshapes (N). Width
= Picwidth * 1.1 ': Set the width to 1.1 times.

Next
N
For n = 1

Activedocument. shapes. Count 'shapes Type Image

Picheight =
Activedocument. shapes (N). Height
Picwidth =
Activedocument. shapes (N). Width
ActiveDocument. Shapes (n). Height =
Picheight * 1.1 'sets the height to 1.1 times

ActiveDocument. Shapes (n). Width
= Picwidth * 1.1 ': Set the width to 1.1 times.

Next
N

End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.