Wow - I blew it!
You guys helped me with this VBA
Sub Finish_Size_Transparent_600x400()
Dim opic As Shape
Dim sngW_Rat As Single
Dim sngH_Rat As Single
Dim Path As String
Dim x As Integer
Const pix_W As Long = 600
Const pix_H As Long = 400
On Error GoTo Err
Set opic = ActiveWindow.Selection.ShapeRange(1)
If opic.Line.Visible Then
sngW_Rat = (ActivePresentation.PageSetup.SlideWidth / (opic.Width + opic.Line.Weight)) * pix_W
sngH_Rat = (ActivePresentation.PageSetup.SlideHeight / (opic.Height + opic.Line.Weight)) * pix_H
Else
sngW_Rat = (ActivePresentation.PageSetup.SlideWidth / (opic.Width)) * pix_W
sngH_Rat = (ActivePresentation.PageSetup.SlideHeight / (opic.Height)) * pix_H
End If
If Val(Application.Version) > 14 Then
sngW_Rat = sngW_Rat * 0.75
sngH_Rat = sngH_Rat * 0.75
End If
Path = "C:\Graphics_ppt\Test_600x400.png"
Call opic.Export(Path, ppShapeFormatPNG, sngW_Rat, sngH_Rat)
redo:
While checkSize(pix_H, 1) <> "Just Right" Or x > 100 'redoes with lower value if larger than spec
If checkSize(pix_H, 1) = "Too Hot" Then sngH_Rat = sngH_Rat - 1 Else sngH_Rat = sngH_Rat + 1
x = x + 1
Call opic.Export(Path, ppShapeFormatPNG, sngW_Rat, sngH_Rat)
Wend
x = 0
While checkSize(pix_W, 0) <> "Just Right" Or x > 100 'redoes with lower value if larger than spec
x = x + 1
If checkSize(pix_W, 0) = "Too Hot" Then sngW_Rat = sngW_Rat - 1 Else sngW_Rat = sngW_Rat + 1
Call opic.Export(Path, ppShapeFormatPNG, sngW_Rat, sngH_Rat)
Wend
Exit Sub 'Normal Exit
Err: 'Error exit
MsgBox "Error " & Err.Description
End Sub
Function checkSize(lngTarget As Long, dimension As Long) As String
Dim objShell As Object
Dim objFolder As Object
Dim objFile As Object
Dim strSize As String
Dim rayw() As String
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:\Graphics_ppt")
Set objFile = objFolder.ParseName("Test_600x400.png")
strSize = objFile.ExtendedProperty("Dimensions")
strSize = Mid(strSize, 2, Len(strSize) - 2)
rayw = Split(strSize, "x")
Select Case Val(rayw(dimension))
Case Is < lngTarget
checkSize = "Too Cold"
Case Is > lngTarget
checkSize = "Too Hot"
Case Is = lngTarget
checkSize = "Just Right"
End Select
End Function
And, I knew as long as I followed certain guidelines (no text boxes near the edges or otherwise it would kill PPT) everything would be great.
Well, yesterday I shared the VBA with a group of grad students and today I had most of them complain to me the VBA kills PPT. And yes, I told them about the text box near the edge issue. But like most people they just marched ahead and ignored my warnings.
So I'm here again asking if there is any way to stop PPT from dying if a text box is used near the edge of a slide with this VBA?
I would like to use it with more of my students but if I do, in it's current state, I'm afraid of being drug thru the streets and hung in the center of the university.
Any help would be incredibly appreciated.