Solved

Macro to format table cells

Posted on 2006-11-14
2
372 Views
Last Modified: 2008-02-01
Hi there,
I need a macro that will scan down through a document, looking for any tables in it. When it finds a table it will scan the cells and if it finds any blank ones it will insert the text "N/A" (without the quotes). It then moves onto the next table (if there is one) does the same and continues on until it reaches the end of the document.

Many thanks in advance

Michael
0
Comment
Question by:daleoran
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 125 total points
ID: 17937515
Hi Mike.

Try this one:

Sub DefaultCellData()
    Dim tbl As Table
    Dim cl As Cell
   
    For Each tbl In ActiveDocument.Tables
        For Each cl In tbl.Range.Cells
            If Len(cl.Range.Text) < 3 Then 'cell range returns visible text + 2 format characters
                cl.Range.Text = "N/A"
            End If
        Next cl
    Next tbl
End Sub
0
 
LVL 10

Author Comment

by:daleoran
ID: 17937704
Brilliant - Many thanks :)

Michael
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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 …
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
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.

786 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