Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
@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 Aug 6 '12 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. –  BeSlayed Aug 6 '12 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 Sep 27 '13 at 13:34
add comment

2 Answers

up vote 11 down vote accepted

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
share|improve this answer
    
One could probably write something similar for open documents. –  Louis Aug 8 '12 at 14:34
    
Thanks! When you say "run as a macro", is that something that is done in the powerpoint/openoffice editor itselt? –  BeSlayed Aug 9 '12 at 16:25
    
@BeSlayed Copy the above code in to a module "(Alt+F12); create a new module; etc.) and run it. –  Louis Aug 10 '12 at 12:32
    
OK, so this is Powerpoint only. Libreoffice seems to use it's own macro language, unfortunately. –  BeSlayed Aug 11 '12 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 Aug 17 '12 at 15:03
show 4 more comments

There is another project for ppt to beamer conversion. I have used it and the major downside was that a 20 slided ppt with about 8 bullets per slide became an over 200 slide beaner. 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 prersentations section. http://www.unc.edu/~monogan/computing/latex/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.