在Powerpoint 2010中将公式转换为图像的宏

时间:2012-11-15 08:15:50

标签: vbscript powerpoint powerpoint-vba powerpoint-2010

我试图预先创建一个宏,它可以将PowerPoint2010演示文稿中的所有方程式转换为图像,同时保留位置和动画效果/顺序。

根据提供的提示here(感谢Steve Rindsberg),我修改了以下脚本:

    Sub ConvertAllShapesToPic()
    Dim oSl As Slide
    Dim oSh As Shape

    On Error Resume Next

    For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            ' modify the following depending on what you want to
            ' convert
            Select Case oSh.Type
                Case msoTextBox, msoEmbeddedOLEObject, msoLinkedOLEObject
                    ConvertShapeToPic oSh
                Case Else
            End Select
        Next
    Next

NormalExit:
    Exit Sub

ErrorHandler:
    Resume Next

End Sub

Sub ConvertShapeToPic(ByRef oSh As Shape)
    Dim oNewSh As Shape
    Dim oSl As Slide

    Set oSl = oSh.Parent
    oSh.Copy
    Set oNewSh = oSl.Shapes.PasteSpecial(ppPasteEnhancedMetafile)(1)
    oSh.PickupAnimation
    oNewSh.ApplyAnimation
    With oNewSh
        .Left = oSh.Left
        .Top = oSh.Top
        Do
            .ZOrder (msoSendBackward)
        Loop Until .ZOrderPosition = .ZOrderPosition
        .AnimationSettings.AnimationOrder = oSh.AnimationSettings.AnimationOrder
    End With
    oSh.Delete

NormalExit:
    Exit Sub

ErrorHandler:
    Resume Next

End Sub

此脚本出现问题:

  1. 所有方程都没有转换成图像。
  2. 一些没有方程式的文本框正在失去其内部动画效果(例如在点击时显示第二个项目符号文本)。
  3. 我准备此脚本的原因是因为当我将PowerPoint 2010转换为Articulate演示时,由于Articulate 09不完全支持PPT2010方程,所以方程式无法正确呈现。

    我有超过100个PPT,几乎所有幻灯片上都有公式。如果没有编程方法,唯一的选择就是手动转换所有方程并重新应用动画效果!

    感谢您提供的任何帮助: - )

    谢谢!

2 个答案:

答案 0 :(得分:0)

关于第一个问题,我的不好:

为此:

For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            ' modify the following depending on what you want to
            ' convert
            Select Case oSh.Type
                Case msoTextBox, msoEmbeddedOLEObject, msoLinkedOLEObject
                    ConvertShapeToPic oSh
                Case Else
            End Select
        Next
Next

替补:

Dim x as long 

For x = ActivePresentation.Slides.Count to 1 Step -1
        Set oSl = ActivePresentation.Slides(x)
        For Each oSh In oSl.Shapes
            ' modify the following depending on what you want to
            ' convert
            Select Case oSh.Type
                Case msoTextBox, msoEmbeddedOLEObject, msoLinkedOLEObject
                    ConvertShapeToPic oSh
                Case Else
            End Select
        Next
Next

当我最初写这篇文章时,我可能只用每张幻灯片的一个方程测试幻灯片。当您单步执行集合和可能的删除成员时,您需要向后逐步执行,否则在删除成员时索引会变得混乱。

答案 1 :(得分:0)

Sub Test()
    Dim oSh As Shape

    For Each oSh In ActivePresentation.Slides(1).Shapes
        DoSomethingToEachShape oSh
    Next

End Sub

Sub DoSomethingToEachShape(oSh As Shape)
    Dim x As Long
    If oSh.Type = msoGroup Then
        For x = 1 To oSh.GroupItems.Count
            DoSomethingToEachShape oSh.GroupItems(x)
        Next
    Else
        Debug.Print oSh.Name
    End If
End Sub