ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

word 宏(图片锐度和对比度)

2026/8/4 6:24:07 拓冰建站 浏览量
word 宏(图片锐度和对比度)

Sub 对比度调整()


For i = 1 To ActiveDocument.InlineShapes.Count
ActiveDocument.InlineShapes(i).PictureFormat.brightness = 0.5 '将嵌入型图片的亮度设置为50
ActiveDocument.InlineShapes(i).PictureFormat.contrast = 0.6
'将嵌入型图片的对比度设置为100
Next i
For i = 1 To ActiveDocument.Shapes.Count
If ActiveDocument.Shapes(i).Type = msoPicture Then '假设浮动型对象是图片时才处理
ActiveDocument.Shapes(i).PictureFormat.brightness = 0.5
'将浮动型图片的亮度设置为50

ActiveDocument.Shapes(i).PictureFormat.contrast = 0.6
'将浮动型图片的对比度设置为100

End If
Next i
End Sub

Sub 锐化()

Dim sha As PictureEffect

For i = 1 To ActiveDocument.InlineShapes.Count '.InlineShapes 指定是嵌入型图片;'0~1对应-100%~100%范围
With ActiveDocument.InlineShapes(i).Fill.PictureEffects
Set sha = .Insert(msoEffectSharpenSoften)
sha.EffectParameters(1).Value = 0.4 '锐化25%
End With
Next i

For i = 1 To ActiveDocument.Shapes.Count 'ActiveDocument.Shapes 默认是除去嵌入型图片的所有类型
With ActiveDocument.InlineShapes(i).Fill.PictureEffects
Set sha = .Insert(msoEffectSharpenSoften)
sha.EffectParameters(1).Value = 0.4 '锐化25%
End With
Next i
End Sub