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
Solved

Round Corners of a table

Posted on 2006-12-01
7
3,237 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
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Re-indent word doc 5 49
Microsoft Word Macros and VBA Scripts 3 61
Need a poor man's PowerPoint 5 129
is it possible to scan a document directly into Microsoft Word 2013? 14 74
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…
The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

840 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