nullpointer
07-17-2016, 05:54 PM
I use the following VBA in PowerPoint to save a slide/image to a png.
Sub png_600x400()
Dim opic As Shape
Dim sngW_Rat As Single
Dim sngH_Rat As Single
Dim Path As String
Const pix_W As Long = 600
Const pix_H As Long = 400
Set opic = ActiveWindow.Selection.ShapeRange(1)
sngW_Rat = ActivePresentation.PageSetup.SlideWidth / opic.Width * pix_W
sngH_Rat = ActivePresentation.PageSetup.SlideHeight / opic.Height * pix_H
'Old path
'Path = Environ("USERPROFILE") & "\Desktop\Temp\Transparent_Test_Image.png"
'New Path
Path = "C:\Temp\Transparent_Test_Image.png"
Call opic.Export(Path, ppShapeFormatPNG, sngW_Rat, sngH_Rat)
End Sub
The problem is the output for this code ends up being 802 x 535 which means I then need to open it in a graphics program and resize it to 600 x 400.
Is there a way to "persuade" the above code to output the right 600 x 400 size?
I appreciate any and all help!
Sub png_600x400()
Dim opic As Shape
Dim sngW_Rat As Single
Dim sngH_Rat As Single
Dim Path As String
Const pix_W As Long = 600
Const pix_H As Long = 400
Set opic = ActiveWindow.Selection.ShapeRange(1)
sngW_Rat = ActivePresentation.PageSetup.SlideWidth / opic.Width * pix_W
sngH_Rat = ActivePresentation.PageSetup.SlideHeight / opic.Height * pix_H
'Old path
'Path = Environ("USERPROFILE") & "\Desktop\Temp\Transparent_Test_Image.png"
'New Path
Path = "C:\Temp\Transparent_Test_Image.png"
Call opic.Export(Path, ppShapeFormatPNG, sngW_Rat, sngH_Rat)
End Sub
The problem is the output for this code ends up being 802 x 535 which means I then need to open it in a graphics program and resize it to 600 x 400.
Is there a way to "persuade" the above code to output the right 600 x 400 size?
I appreciate any and all help!