Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:18:03+00:00 2026-05-27T08:18:03+00:00

I want to automatically extract data from tables of a Word document. I do

  • 0

I want to automatically extract data from tables of a Word document. I do this by iterating over all tables in VBA. I.e.

For Each tbl In wdDoc.Tables
Next

Is it possible to find the caption for a given table? i.e. the document has
“Table 3:” and then the table.

Note that not all the tables in the document have got a caption and therefore the table numbers in captions are different than the document table enumeration.

Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:18:04+00:00Added an answer on May 27, 2026 at 8:18 am

    Unfortunately, table captions are not actually associated with their tables through the Word Object Model. When a table caption is created, it is just text placed in a separate Paragraph object.

    So, the short answer is that no, there is no good way to find the caption for a given table.

    I did write some code that may help you though. It basically iterates through all Paragraph objects in the document and looks for the “Caption” style (alternatively, you could look for text formatted “Table #:”, or whatever you’d like). If the very next Paragraph contains tables, it places the text of the caption into the first cell of the first table found.

        Dim p As Paragraph
        Dim lastParagraphWasCaption As Boolean
        Dim lastCaptionText As String
        lastParagraphWasCaption = False
    
        For Each p In ActiveDocument.Paragraphs
            If lastParagraphWasCaption And p.Range.Tables.Count > 0 Then
                p.Range.Tables(1).Cell(1, 1).Range.Text = lastCaptionText
            End If
    
            If p.Range.Style = "Caption" Then
                lastParagraphWasCaption = True
                lastCaptionText = p.Range.Text
            Else
                lastParagraphWasCaption = False
            End If
        Next
    

    Keep in mind that this is just an example of how you could tie together a caption with its table. With that said, it is not a very reliable method and I would not recommend using it unless you absolutely need to because table captions could presumably not have the caption styling, or there could be caption styling on something that isn’t a caption, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to automatically generate VB.NET forms using tables from a SQL Server database
I'd like to copy a table like this in a word document and extract
I get poorly formatted invoice-related email from my payment gateway. I want to automatically
I want to automatically add files to an Xcode project that is created from
I want to automatically remove all explicit types and exchange them with the var
I want to automatically invoke my application at 12.00 am,This kind of process ,how
I have some TextViews in my app that I want updated automatically each 5
I want to automatically put @Valid constraints on all my properties. Example: public class
I want to automatically commit the database when we copy files from one branch
I want to automatically define incrementing variable names. So instead of this: $Var1 =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.