Solved

Round Corners of a table

Posted on 2006-12-01
7
3,235 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now