Solved

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

Posted on 2014-04-03
2
254 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
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…
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 Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

777 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