|
Sub InsertImage()
'定义变量
Dim imagePath As String
Dim newPic As Shape
'指定图片路径
imagePath = "C:\Users\userName\Pictures\example.jpg" '请替换为您自己的图片路径
'插入图片
Set newPic = ActiveDocument.Shapes.AddPicture( _
FileName:=imagePath, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=0, _
Top:=0, _
Width:=50, _
Height:=50 _
)
'设置宽度和高度
newPic.LockAspectRatio = msoTrue
newPic.Width = CentimetersToPoints(5)
'设置浮动效果
newPic.WrapFormat.Type = wdWrapSquare
newPic.WrapFormat.Side = wdWrapBoth
newPic.WrapFormat.DistanceTop = CentimetersToPoints(0.25)
newPic.WrapFormat.DistanceBottom = CentimetersToPoints(0.25)
End Sub |
|