Solved

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

Posted on 2014-04-03
2
252 Views
Last Modified: 2014-04-04
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
Comment
Question by:AndreasHermle
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 39974401
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
 

Author Closing Comment

by:AndreasHermle
ID: 39978055
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:

705 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

16 Experts available now in Live!

Get 1:1 Help Now