27

I'm interested in converting some .ppt files into beamer/.tex (or, better, .org) format. I can find numerous discussions of converting from beamer to .ppt but not the other way round. Is there any (reasonable) way to do this?

4
  • 1
    @PauloCereda has an ongoing project about this, however, as far as I know it's still in its infancy. But no matter how complicated it is, Powerpoint has structural problems such as encouraging bullet lists etc. so the best would be redesigning the slides.
    – percusse
    Commented Aug 6, 2012 at 1:03
  • 1
    percusse: I don't mind doing some hand-editing afterwards, but I am curious about anything that could at least do an initial dump from .ppt to .tex or .org. Commented Aug 6, 2012 at 1:13
  • I'm writing some stuff that will convert a pptx (not ppt) presentation to latex/beamer tex files. More info: timdams.com/2013/09/26/…
    – Tim Dams
    Commented Sep 27, 2013 at 13:34
  • The best solution a I found is (1) export to libreoffice (2) unzip it to copy all the images (2) paste de list of files Rmarkdown document (2) change every "foo.jpg" file by ![foo](foo.jpg) (4) Insert a line with ### Foo before of that code (that make a frame for that image. (5) Add the lost text at hand, or copy from the presentation and paste in RStudio, and (6) export the R makdown to Beamer.
    – Fran
    Commented Sep 24, 2019 at 22:38

3 Answers 3

21

If you are interested I can share with you some VBA code I have developed to do just that. You can load it as a macro and run it. It will give you a txt file of the same name as the ppt and dump the pictures as png files. It will also show the number of the slide it came from. I want to eventually take the VBA code and create a stand alone application but the time is not there yet.

' this code extracts text from PPT(X) and saves to latex beamer body

Public Sub Extract2Beamer()
    Dim objPresentation As Presentation
    Set objPresentation = Application.ActivePresentation

    Dim objSlide As Slide
    Dim objshape As Shape
    Dim objShape4Note As Shape
    Dim hght As Long, wdth As Long
    Dim objFileSystem
    Dim objTextFile
    Dim objGrpItem As Shape

    Dim Name As String, Pth As String, Dest As String, IName As String, ln As String, ttl As String, BaseName As String
    Dim txt As String
    Dim p As Integer, l As Integer, ctr As Integer, i As Integer, j As Integer
    Dim il As Long, cl As Long
    Dim Pgh As TextRange

    Name = Application.ActivePresentation.Name
    p = InStr(Name, ".ppt")
    l = Len(Name)
    If p + 3 = l Then
      Mid(Name, p) = ".txt"
    Else
      Name = Name & ".txt"
    End If
    BaseName = Left(Name, l - 4)
    Pth = Application.ActivePresentation.Path
    Dest = Pth & "\" & Name
    ctr = 0
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")

    Set objTextFile = objFileSystem.CreateTextFile(Dest, True, True)
    objTextFile.WriteLine "\section{" & Name & "}"
    With Application.ActivePresentation.PageSetup
        wdth = .SlideWidth
        hght = .SlideHeight
    End With


    For Each objSlide In objPresentation.Slides
        objTextFile.WriteLine ""
        ttl = "No Title"
        If objSlide.Shapes.HasTitle Then
          ttl = objSlide.Shapes.Title.TextFrame.TextRange.Text
        End If
        objTextFile.WriteLine "\subsection{" & ttl & "}"
        objTextFile.WriteLine "\begin{frame}[<+-| alert@+>]{" & ttl & "}"
        objTextFile.WriteLine "%" & Name & " Nr:" & objSlide.SlideIndex

        For Each objshape In objSlide.Shapes

            If objshape.HasTextFrame = True Then
                If Not objshape.TextFrame.TextRange Is Nothing Then
                    il = 0
                    For Each Pgh In objshape.TextFrame.TextRange.Paragraphs

                        If Not objshape.TextFrame.TextRange.Text = ttl Then
                            cl = Pgh.Paragraphs.IndentLevel
                            txt = Pgh.TrimText
                            txt = Replace(txt, "&", "\&")
                            If cl > il Then
                               objTextFile.WriteLine "\begin{itemize}"
                                il = cl
                            ElseIf cl < il Then
                                objTextFile.WriteLine "\end{itemize}"
                                il = cl
                            End If
                            If il = 0 Then
                                objTextFile.WriteLine txt
                            Else
                                objTextFile.WriteLine "\item " + txt
                            End If
                        End If
                    Next Pgh
                    If il > 0 Then
                      For i = 1 To il
                        objTextFile.WriteLine "\end{itemize}"
                      Next i
                    End If
                End If
            ElseIf objshape.HasTable Then
              ln = "\begin{tabular}{|"
              For j = 1 To objshape.Table.Columns.Count
              ln = ln & "l|"
              Next j
              ln = ln & "} \hline"
              objTextFile.WriteLine ln
              With objshape.Table
                For i = 1 To .Rows.Count
                    If .Cell(i, 1).Shape.HasTextFrame Then
                        ln = .Cell(i, 1).Shape.TextFrame.TextRange.Text
                    End If

                    For j = 2 To .Columns.Count
                        If .Cell(i, j).Shape.HasTextFrame Then
                            ln = ln & " & " & .Cell(i, j).Shape.TextFrame.TextRange.Text
                        End If
                    Next j
                    ln = ln & "  \\ \hline"
                    objTextFile.WriteLine ln
                Next i
                objTextFile.WriteLine "\end{tabular}" & vbCrLf
              End With
            ElseIf (objshape.Type = msoGroup) Then
                For Each objGrpItem In objshape.GroupItems
                    If objGrpItem.HasTextFrame = True Then
                        If Not objGrpItem.TextFrame.TextRange Is Nothing Then
                           shpx = objGrpItem.Top / hght
                           shpy = objGrpItem.Left / wdth
                           ' this could need adjustment (Footers textblocks)
                           If shpx < 0.1 And shpy > 0.5 Then
                            objTextFile.WriteLine ("%BookTitle: " & objGrpItem.TextFrame.TextRange.Text)
                            ElseIf shpx < 0.1 And shpy < 0.5 Then
                            objTextFile.WriteLine ("%FrameTitle: " & objGrpItem.TextFrame.TextRange.Text)
                            Else
                            objTextFile.WriteLine ("%PartTitle: " & objGrpItem.TextFrame.TextRange.Text)
                           End If
                        End If
                    End If
                 Next objGrpItem
            ElseIf (objshape.Type = msoPicture) Then
                IName = BaseName + "-img" & Format(ctr, "0000") & ".png"
                objTextFile.WriteLine "\includegraphics{" & IName & "}"
                Call objshape.Export(Pth & "\" & IName, ppShapeFormatPNG, , , ppRelativeToSlide)
                ctr = ctr + 1
            ElseIf objshape.Type = msoEmbeddedOLEObject Then
                If objshape.OLEFormat.ProgID = "Equation.3" Then
                    IName = BaseName + "-img" & Format(ctr, "0000") & ".png"
                    objTextFile.WriteLine "\includegraphic{" & IName & "}"
                    Call objshape.Export(Pth & "\" & IName, ppShapeFormatPNG, , , ppRelativeToSlide)
                    ctr = ctr + 1
                End If
            End If
        Next objshape

        Set objShape4Note = objSlide.NotesPage.Shapes(2)
        If objShape4Note.HasTextFrame = True Then
            If Not objShape4Note.TextFrame.TextRange Is Nothing Then
                objTextFile.WriteLine vbCrLf & "%Notes: " & objShape4Note.TextFrame.TextRange.Text
            End If
        End If

        objTextFile.WriteLine vbCrLf & "\end{frame}" & vbCrLf
        'to test on the first 3 slides
        'If objSlide.SlideIndex >= 3 Then
        '    Exit For
        'End If
    Next objSlide

    objTextFile.Close
    Set objTextFile = Nothing
    Set objFileSystem = Nothing
End Sub
9
  • 1
    One could probably write something similar for open documents.
    – Louis
    Commented Aug 8, 2012 at 14:34
  • Thanks! When you say "run as a macro", is that something that is done in the powerpoint/openoffice editor itselt? Commented Aug 9, 2012 at 16:25
  • @BeSlayed Copy the above code in to a module "(Alt+F12); create a new module; etc.) and run it.
    – Louis
    Commented Aug 10, 2012 at 12:32
  • OK, so this is Powerpoint only. Libreoffice seems to use it's own macro language, unfortunately. Commented Aug 11, 2012 at 1:37
  • 1
    @BeSlayed: If you are in a problem right now I can help you with one or presentations. I intend to make the above alone standing, but at the moment I have to prepare for two and half days of lecturing and I can't switch over to coding -- I will lose sight of my students.
    – Louis
    Commented Aug 17, 2012 at 15:03
12

There is another project for ppt to beamer conversion. I have used it and the major downside was that a 20 slide ppt with about 8 bullets per slide became an over 200 slide beamer. I also had to manually fix about 20+ LaTeX errors per slide. And there are some difficulties with graphics.

I used this about 4 years ago and I was able to convert quickly the 72 ppt slide shows for a semester course in an afternoon.

The link are at this web site at the presentations section: http://www.unc.edu/~monogan/computing/latex/

1
  • 1
    The links are down now, but they are on the wayback machine. The executable program is gone, but the source code is still accessible.
    – Ernir
    Commented Sep 1, 2015 at 1:32
9

Here is the updated link to where you can down Jim Stimson's RTFBeamer program (see under "RTFBeamer — Converts “Outline/RTF” versions of PowerPoint slides into Beamer files"):

http://stimson.web.unc.edu/software/

All credit to Jim Stimson for creating this public good.

1
  • 1
    I am afraid to say that it doesn't work with animated shapes. Maybe it works with text, but it doesn't with more advanced content. Anyway, this effort is appreciated.
    – Diaa
    Commented Jun 9, 2016 at 6:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .