Thread: [Solved] State management?
View Single Post
 
Old 06-20-2018, 08:33 AM
d4okeefe d4okeefe is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default

The code is slow, I think, because you set a range object for every table cell in the document.
Code:
Set rng = tbl.Cell(xrow, xcol).Range
Rather than testing each cell for a tab, maybe you could use Range.Find to identify all tabs in the document, then test if that tab is inside of a table.
Code:
Sub test_for_tab_inside_table()
    Dim r As Range
    Set r = ActiveDocument.Content
    With r.Find
        .ClearFormatting
        .Text = "^t"
        .Execute
        Do While .Found
            If r.Information(wdWithInTable) Then
                'Do the work
            End If
            .Execute
        Loop
    End With
End Sub
That said, I get the sense that you care more about the data in the document than the document's appearance. (Otherwise, the PDF would work fine for you.) You may want to look into setting up a database, and then extract data from the Word file into that. Or maybe the PDF was created from a database that already exists?

Last edited by d4okeefe; 06-20-2018 at 01:41 PM.
Reply With Quote