Solved

Run macro on tables where specific cells are blank.

Posted on 2015-01-30
2
88 Views
Last Modified: 2016-02-10
Dear Experts,

can somebody help me re-write this code so that ...
... only tables get worked on where the 2nd and 3nd cell in the first row are blank, i.e. Cell(Row:=1;Column:=2) and Cell(Row:=1;Column:=3) are blank.

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

Regards, Andreas

Sub Format_First_Row_All_Tables

Dim tbl as table

For Each tbl In ActiveDocument.Tables
        With tbl.rows.First
            .Range.Font.Name = "Verdana"
            .Range.Font.Size = 7.5
            .Range.Font.Bold = True
            .Shading.BackgroundPatternColor = wdColorGray25
            .HeadingFormat = True
            .HeightRule = wdRowHeightAtLeast
            .Height = CentimetersToPoints(0.9)
        End With
 Next tbl

End Sub

Open in new window

0
Comment
Question by:AndreasHermle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40580912
I think the easiest way is to check the length of the cell ranges. The length of the range of an empty cell is 2.
Sub Format_First_Row_All_Tables()

Dim tbl As Table

For Each tbl In ActiveDocument.Tables
    If Len(tbl.Cell(1, 2).Range) + Len(tbl.Cell(1, 3).Range) = 4 Then
        With tbl.Rows.First
            .Range.Font.Name = "Verdana"
            .Range.Font.Size = 7.5
            .Range.Font.Bold = True
            .Shading.BackgroundPatternColor = wdColorGray25
            .HeadingFormat = True
            .HeightRule = wdRowHeightAtLeast
            .Height = CentimetersToPoints(0.9)
        End With
    End If
 Next tbl

Open in new window

0
 

Author Closing Comment

by:AndreasHermle
ID: 40583459
Hi Graham,

great, this did the trick. Thank you very much for your professional and swift support.

Regards, Andreas
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

707 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