Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Convert PowerPoint tables to HTML

Problem

You have a table in PowerPoint and want to use it as a stand-alone web page or to include it as a table in another web page you're building. Saving the slide as HTML results in very complex, uneditable HTML that you can't easily use in another program.

Solution

Select the PowerPoint table you want to convert to HTML then run the macro below.

Sub TableToHTML()    
    Dim oTable As Table
    Dim oSh As Shape
    Dim lColumn As Long
    Dim lRow As Long
    Dim sTableHTML As String

    ' No error checking here
    ' It's up to user to select a PowerPoint table before running this
    ' Note: POWERPOINT table, not pasted Word or Excel tables

    ' Start table off:
    sTableHTML = "<html>" & vbCrLf _
        & "<head>" & vbCrLf _
        & "</head>" & vbCrLf _
        & "<body>" & vbCrLf & vbCrLf _
        & "<table>" & vbCrLf

    Set oTable = ActiveWindow.Selection.ShapeRange(1).Table
    With oTable
        For lRow = 1 To .Rows.Count
            sTableHTML = sTableHTML & vbTab & "<tr>" & vbCrLf
            For lColumn = 1 To .Columns.Count
                sTableHTML = sTableHTML _
                    & vbTab & vbTab & "<td>" _
                    & .Cell(lRow, lColumn).Shape.TextFrame.TextRange.Text _
                    & "</td>" & vbCrLf
            Next
            sTableHTML = sTableHTML & vbTab & "</tr>" & vbCrLf
        Next
    End With

    ' finish up
    sTableHTML = sTableHTML & "</table>" & vbCrLf _
        & "</body>" & vbCrLf _
        & "</html>" & vbCrLf

    ' display the result in Immediate window
    ' Press Ctrl+G if you don't see the output
    Debug.Print sTableHTML

    ' Save to file
    Dim iFileNum As Integer
    iFileNum = FreeFile()
    Open "C:\Table.htm" For Output As #iFileNum
    Print #iFileNum, sTableHTML
    Close #iFileNum    
End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Convert PowerPoint tables to HTML
http://www.pptfaq.com/FAQ00748_Convert_PowerPoint_tables_to_HTML.htm
Last update 07 June, 2011
Created: