select table in word doc using vba

Posted on 2006-05-22
Last Modified: 2008-02-01
I wish to change the font size in a table that is embedded in a word doc using vba.  My question is:  

How do you select a table imbedded in a word doc with vba?
Question by:sander69
    LVL 76

    Expert Comment

    To find a table in VBA, it is best to know it's sequential number in the document:

    Dim tbl as Table
    Set tbl = ActiveDocument.Tables(3)
    tbl.Range.Font.Size = 14

    otherwise, you would have to know something about the table.

    Of course you could always bookmark it,

        Dim tbl As Table
        Set tbl = ActiveDocument.Bookmarks("bmkThisTable").Range.Tables(1)
        tbl.Range.Font.Size = 8


    Author Comment

    Is there a way to loop through all of them?  I assume they are indexed in some manner.
    LVL 76

    Accepted Solution

    Absolutely. The index is in the order that they appear on the document , i.e. a table's index will change if tables are added or deleted earlier in the document. However there is a Tables Collection, so if you can easily step through them all.

    Dim tbl as Table
    For each tbl in ActiveDocument.Tables
      tbl.Range.Font.Size = 14
    Next tbl


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
    A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
    This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
    In a previous video Micro Tutorial here at Experts Exchange (, I explained how to get a free, one-month trial of Office …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now