好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 chuqi26 于 2024-1-21 08:18 编辑
Sub AdjustImageProperties()
Dim selectedShapes As Word.Shapes
Dim shp As Word.Shape
Dim brightness As Single
Dim contrast As Single
Dim sharpness As Single
Dim applyToAll As Boolean
' 询问用户是否要应用到所有图片
applyToAll = MsgBox("Do you want to apply settings to all images?", vbYesNo) = vbYes
' 用户输入清晰度、亮度和对比度的值
sharpness = InputBox("Enter sharpness value (范围 -1 to 1, 默认0):", "Image Sharpness", 0)
brightness = InputBox("Enter brightness value (范围-1 to 1, 默认0.5):", "Image Brightness", 0.5)
contrast = InputBox("Enter contrast value (范围-1 to 1, 默认0.5):", "Image Contrast", 0.5)
' 检查用户是否选择了文档中的某些图片
If Selection.Type = wdSelectionShape Then
Set selectedShapes = Selection.ShapeRange
ElseIf applyToAll Then
Set selectedShapes = ActiveDocument.Shapes
Else
MsgBox "No images selected or found.", vbExclamation
Exit Sub
End If
' 应用用户设置的属性
For Each shp In selectedShapes
If shp.Type = msoPicture Then
' 对于图片,设置清晰度、亮度和对比度
shp.PictureFormat.Brightness = brightness
shp.PictureFormat.Contrast = contrast
shp.PictureFormat.Sharpness = sharpness
End If
Next shp
MsgBox "Image adjustments applied successfully!", vbInformation
End Sub
|
|