Home > Software engineering >  How to use the Word VBA resized images?
How to use the Word VBA resized images?

Time:09-22

I now need to put all the pictures of the entire document, is set to 125% of their original size, VBA can do it?

CodePudding user response:

In Word start recording macros, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,
Remind: the function of the Word to find the next picture in the scroll bar at the bottom right corner,

CodePudding user response:

reference 1st floor zhao4zhong1 response:
start recording macros in the Word, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,
Remind: the function of the Word to find the next picture in the scroll bar at the bottom right,
if record can solve a problem, I will not come here to ask,

CodePudding user response:

Fyi:
 Application. The Target=wdBrowseGraphic 
Application. The Next
Selection. InlineShapes (1). LockAspectRatio=msoTrue
Selection. InlineShapes (1). Height=1262.85
Selection. InlineShapes (1). The Width=1584 #

CodePudding user response:

reference zhao4zhong1 reply: 3/f
are for reference only:
 Application. The Target=wdBrowseGraphic 
Application. The Next
Selection. InlineShapes (1). LockAspectRatio=msoTrue
Selection. InlineShapes (1). Height=1262.85
Selection. InlineShapes (1). The Width=1584 #
this not line, I want all the size of the image set to 1.25 times their original size, rather than put all images into a fixed size,

CodePudding user response:

Forget it, I have modified the problem, why, the following statement will be prompted to "attribute of the invalid use
"Selection. InlineShapes (1). ScaleHeight Factor:=100, RelativeToOriginalSize:=True

CodePudding user response:

Factor:=100 said, 10000% is too big,
100% should be Factor:=1.0

CodePudding user response:

Also, see the help in InlineShape ScaleHeight is attribute , ShapeRange. ScaleHeight is method ,

CodePudding user response:

Find on the net, has tested

 Sub Test () 
Dim myShape As the Variant
Application. ScreenUpdating=False
With ActiveDocument
For Each myShape. In Shapes
With myShape
. ScaleHeight 0.5, True
. ScaleWidth 0.5, True
End With
Next
For Each myShape. In InlineShapes
MyShape. Select
The Set myShape=. InlineShapes (1). ConvertToShape
With myShape
. ScaleHeight 1.5, True, msoScaleFromMiddle
. ScaleWidth 1.5, True, msoScaleFromMiddle
End With
Next
End With
Application. ScreenUpdating=True
End Sub

CodePudding user response:

The upstairs has been resolved,
  •  Tags:  
  • VBA
  • Related