Retrieve table style and paragraph styles of current table and display them in a MsgBox

Dear Experts:

For the currently selected table I would like to retrieve ...
... the table style (built on or custom table style) ...
... the paragraph style of the first cell in the first row and ...
... the paragraph style of the first cell in the second row ...

and display these styles in a MsgBox (using VBA), such as:
The currently selected table (5th table in the document) features the following styles:
Table Style: MyCustomTableStyleGrey
Paragraph Style of first cell in first row: Heading 1
Paragraph Style of first cell in second row: Normal

Help is very much appreciated. Thank you very much in advance.

Regards, Andreas
Andreas HermleTeam leaderAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
Hi Andreas, here's my effort
Sub ShowTableStyle()
    With Selection.Tables(1)
        MsgBox "Table Style: " & .Style & vbCrLf & _
               "Row1, Cell1 para style: " & .Cell(1, 1).Range.Paragraphs.First.Style & vbCrLf & _
               "Row2, Cell1 para style: " & .Cell(2, 1).Range.Paragraphs.First.Style
    End With
End Sub

Open in new window

0
 
Andreas HermleTeam leaderAuthor Commented:
Hi Graham,

long time no hear, but I was pretty sure that you would answer my question and as was the case 400 times before, you solved the question :-)
0
 
Andreas HermleTeam leaderAuthor Commented:
Hi Graham,

thank you very much for your professional help. It works as desired. Great help.

have a nice christmas :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.