Word macro to extract tables from a WORD document

Discussion in 'Word Programming' started by Generic Usenet Account, May 10, 2011.

  1. Hi,

    Can someone out there kindly provide a word macro that extracts all
    the tables in a WORD document into a separate document, with a blank
    like separating the tables?

    Thanks in advance!
    Choi
     
    Generic Usenet Account, May 10, 2011
    #1
    1. Advertisements

  2. Generic Usenet Account

    Jay Freedman Guest

    Sub ExtractTables()
    Dim src As Document
    Dim dst As Document
    Dim tbl As Table
    Dim rg As Range

    Set src = ActiveDocument
    Set dst = Documents.Add

    For Each tbl In src.Tables
    Set rg = dst.Range
    rg.Collapse wdCollapseEnd
    rg.FormattedText = tbl.Range.FormattedText
    rg.Collapse wdCollapseEnd
    rg.Text = vbCr
    Next
    End Sub
     
    Jay Freedman, May 11, 2011
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.