Name

querytable.WebPreFormattedTextToColumns [= setting]

Synopsis

For web queries, True parses rows in <PRE> (preformatted) sections of a web page and places aligned items in separate cells. False parses each row in <PRE> sections as a single data item and places the entire row in one cell.

For example, the following code imports a sample web page and parses rows in <PRE> sections as multiple cells:

    Set qt = ActiveSheet.QueryTables(1)
    qt.Connection = "URL;file://" & ThisWorkbook.Path & "\preblocks.html"
    qt.WebSelectionType = xlAllTables
    qt.WebPreFormattedTextToColumns = True
    qt.Refresh

The web page containing items parsed into cells looks like this:

    <html>
    <body>
    <pre>
    1    2    3    4
    5    6    7    8
    </pre>
    </body>
    </html>

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.