【发布时间】:2016-03-31 12:46:49
【问题描述】:
我正在 PowerPoint VBA 中创建一个宏以从当前幻灯片中导出图像。导出图像将是第一个宽度大于 250 个单位的图像。图像存储为Shape,因此我执行For Each ... Next 循环来执行此操作。代码运行良好。
Function FindAndSavePicture() As String
'
' Find the target picture at the active windows
'
'
Dim myTempPath As String
myTempPath = "C:\Users\" & Environ$("USERNAME") _
& "\AppData\Local\Microsoft\Windows\pic_VBA.jpg"
With ActiveWindow.Selection.SlideRange
For Each s In .Shapes
Debug.Print s.Name
If s.Type = msoPicture And s.Width > 250 Then
' Show scale
Debug.Print "s.Width=" & s.Width ' s.Width=323,3931
Debug.Print "s.Height=" & s.Height ' s.Height=405
' Save pic in file system
s.Export myTempPath, ppShapeFormatJPG
' assign the return value for this function
FindAndSavePicture = myTempPath
Exit For
End If
Next
End With
End Function
问题
导出的图像pic_VBA.jpg 比 PowerPoint 中显示的要小得多。 我想要图片的原始尺寸。 这个由 VBA pic_VBA.jpg 导出的图片尺寸为 331 x 413。如果我使用另存为图片...手动导出图像,导出的图像pic_SaveAs.jpg的尺寸为692 x 862,即原始尺寸。
-
pic_VBA.jpg尺寸:331 x 413 -
pic_SaveAs.jpg尺寸:692 x 862(原始尺寸)
我测试过的内容
s.Export myTempPath, ppShapeFormatJPG, s.Width, s.Height, ppScaleXY
它不起作用。导出图像的尺寸为 150 x 413
问题
那么,如何使用 vba 在 PowerPoint 中调整导出图像的大小?
相关信息
【问题讨论】:
标签: image vba export powerpoint