Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Detect first one-row-table in document and display the index number in a msgbox

Dear Experts:

I would like to run a macro with the following requirements:

Search for the first one-row table in the current document and if found display the index number in a msgbox.

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

Regards, Andreas
0
Andreas Hermle
Asked:
Andreas Hermle
1 Solution
 
GrahamSkanRetiredCommented:
Hi Andreas,
 I'm sure that you could do this yourself, but see if this does it:
Sub FirstSingle()
    Dim tbl As Table
    Dim i As Integer
    
    For Each tbl In ActiveDocument.Tables
        i = i + 1
        If tbl.Rows.Count = 1 Then
            MsgBox "First single-row table is No: " & i
            Exit For
        End If
    Next tbl
End Sub

Open in new window

0
 
Andreas HermleTeam leaderAuthor Commented:
thank you very much for your great help. I do quite a lot of code writing myself by mostly tweaking your codes but sometimes I got stuck with even the easiest things.

Regards, Andreas
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.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now