Solved

Round Corners of a table

Posted on 2006-12-01
7
3,239 Views
Last Modified: 2012-05-05
Hi experts,

I want to format a table with rounded corners - is there any way of doing this?

Cheers,
Norb.
0
Comment
Question by:Norbert2000
[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
  • 2
7 Comments
 
LVL 22

Expert Comment

by:Dreamboat
ID: 18055051
No.
Sorry.
Use graphics.
0
 
LVL 1

Author Comment

by:Norbert2000
ID: 18059112
I assume you would make a graphical box (with rounded corners) and placed the table over it?  Can you do that with a table that grows and shrinks via automation?
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 18059688
Do you want the entire table to have rounded corners? Or the individual cells?
If the individual cells, you could use a graphic, create a row, then make an autotext entry from it.

I'm assuming that since no coders have chimed in, this could be painful using VBA (or at least painful to consider doing it for free?).
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 18068721
The procedure below will replace the outer table borders with a rounded rectangle. It would be somewhere between extremely difficult and impossible to make the border adjust dynamically, does it for the table passed into it.

You can test it on the first table in the active document like this:

Sub CallRC()
 RoundCorners activedocument.tables(1)
end sub

I don't know if it is rigorous enough, but it works in simple tests.

Sub RoundCorners(tbl As Table)
    Dim sh As Shape
    Dim c As Integer
    Dim r As Integer
    Dim col As Column
    Dim rw As Row
    Dim cl As Cell
    Dim tblH As Single
    Dim tblW As Single
    Dim doc As Document
    'delete any existing autoshape(s)
    On Error GoTo RoundCornersError
    tbl.Range.ShapeRange.Delete
    For r = 1 To tbl.Rows.Count
        For c = 1 To tbl.Columns.Count
            Set cl = tbl.Cell(r, c)
            If r = 1 Then
                cl.Borders(wdBorderTop).LineStyle = wdLineStyleNone
            Else
                cl.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
            End If
            If c = 1 Then
                cl.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
            Else
                cl.Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
            End If
            If r = tbl.Rows.Count Then
                cl.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
            End If
            If c = tbl.Rows.Count Then
                cl.Borders(wdBorderRight).LineStyle = wdLineStyleNone
            End If
        Next c
    Next r
    For Each col In tbl.Columns
        tblW = tblW + col.Width
    Next col
    For Each rw In tbl.Rows
        rw.HeightRule = wdRowHeightExactly
        tblH = tblH + rw.Height
    Next rw
    Set doc = tbl.Parent
    Set sh = doc.Shapes.AddShape(msoShapeRoundedRectangle, 0, 0, tblW, tblH, tbl.Range)
    sh.Fill.Transparency = 1
    sh.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    sh.Left = tbl.Range.Information(wdHorizontalPositionRelativeToPage) - doc.PageSetup.LeftMargin
RoundCornersExit:
Exit Sub
RoundCornersError:
    Select Case Err.Number
    Case 5852 'Object not available (no shapes anchored to table range)
        Resume Next
    Case Else
        MsgBox "Unexpected error - " & Err.Description
        Resume RoundCornersExit
    End Select
 
End Sub



0
 
LVL 1

Author Comment

by:Norbert2000
ID: 18863075
I am really sorry I didn't except this solution sooner - it does exactly what I want.

Thank you very much.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
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.

728 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