Can't get rid of spaces above table rows

User avatar
Peter Kinross
5StarLounger
Posts: 854
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Can't get rid of spaces above table rows

Post by Peter Kinross »

Can't get rid of spaces above table rows.
tried everything I can think of.
You do not have the required permissions to view the files attached to this post.
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 71153
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Can't get rid of spaces above table rows

Post by HansV »

I don't know what causes it, but the table sits inside a frame.
I converted the table to text, moved the text out of the frame, deleted the frame, and converted the text to a table again. This is the result:

Why.docx
You do not have the required permissions to view the files attached to this post.
Regards,
Hans

User avatar
macropod
4StarLounger
Posts: 458
Joined: 17 Dec 2010, 03:14

Re: Can't get rid of spaces above table rows

Post by macropod »

Simply change the table's wrapping from 'Around' to 'None', then you can delete the empty paragraph, after which you can restore the 'Around' wrapping.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
Peter Kinross
5StarLounger
Posts: 854
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Can't get rid of spaces above table rows

Post by Peter Kinross »

Thanks Hans, converting to text then back to table too complicated.
I did the wrapping thing, although I had already done it. Couldn't find any para markers to delete.
In the end I used the code below, (I'm pretty sure from Hans) that I had forgotten about. It works a treat.
Thanks all.

Code: Select all

Sub ReFormatTable()
Dim c As Cell
On Error GoTo Err_ReFormatTable
If Selection.Information(wdWithInTable) <> True Then
  MsgBox "The cursor is not in a table", vbOKOnly
  GoTo Exit_ReFormatTable
End If
Application.ScreenUpdating = False
Selection.Tables(1).Select
Selection.Font.Name = "Calibri"
Selection.Font.Size = 11
With Selection.ParagraphFormat
    .SpaceBefore = 0
    .SpaceBeforeAuto = False
    .SpaceAfter = 0
    .SpaceAfterAuto = False
    .LineSpacingRule = wdLineSpaceSingle
    .LineUnitBefore = 0
    .LineUnitAfter = 0
End With
Selection.Rows.HeightRule = wdRowHeightExactly
Selection.Rows.Height = CentimetersToPoints(0.5)
Selection.Tables(1).Select
For Each c In Selection.Cells
    With c
        Cntr = Cntr + 1
        If Cntr = 1 Then
            .VerticalAlignment = wdAlignVerticalTop
        End If
        .TopPadding = CentimetersToPoints(0.05)
        .BottomPadding = CentimetersToPoints(0.05)
        .LeftPadding = CentimetersToPoints(0.05)
        .RightPadding = CentimetersToPoints(0.05)
        .WordWrap = True
        .FitText = False
    End With
Next c
With Selection.Tables(1).Rows(1)
    .Alignment = wdAlignRowLeft
    .Height = CentimetersToPoints(0.7)
    .Cells.VerticalAlignment = wdCellAlignVerticalBottom
End With   'Selection.Tables(1).Rows(1)
Exit_ReFormatTable:
Application.ScreenUpdating = True
Exit Sub

Err_ReFormatTable:
Application.ScreenUpdating = True
MsgBox Err.Description
GoTo Exit_ReFormatTable
Resume
End Sub
Avagr8day, regards, Peter

User avatar
Peter Kinross
5StarLounger
Posts: 854
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Can't get rid of spaces above table rows

Post by Peter Kinross »

Whoops, not real good!
The doc text flows around the table. Setting wrapping to either 'None' or 'Around' makes no diff. Creating huge formatting probs. What I need is to set table wrapping to 'Top & Bottom' as I can do with graphics, but probably can't be done.
Avagr8day, regards, Peter

User avatar
Peter Kinross
5StarLounger
Posts: 854
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Can't get rid of spaces above table rows

Post by Peter Kinross »

I think I'm OK. The probs were because I used that code on about 5 tables one after another, the result was chaos. Doing one table at a time seems just fine.
Although I would love to know if there is a way of doing the 'Top & Bottom' wrap for a table.
Again, huge thanks to all. The Lounge Rocks!
Avagr8day, regards, Peter

User avatar
StuartR
Administrator
Posts: 11367
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Can't get rid of spaces above table rows

Post by StuartR »

If you set the text wrapping for the table to "None" then you get the same effect as "Top & Bottom"
You do not have the required permissions to view the files attached to this post.
StuartR


User avatar
Peter Kinross
5StarLounger
Posts: 854
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Can't get rid of spaces above table rows

Post by Peter Kinross »

Thanks Stuart. If only.
When I re-formatted 5 of the tables in the doc one after another, setting it to 'None' for each table had the same effect as 'Around'. Maybe the doc became horribly faulty where nothing worked as it should. Who knows.
Ah well, as I now have the doc working (I re-created it from scratch then used the code), the wrapping is now just to satisfy my curiosity.
Avagr8day, regards, Peter

jolas
2StarLounger
Posts: 138
Joined: 02 Feb 2010, 23:58

Re: Can't get rid of spaces above table rows

Post by jolas »

Try selecting the table. Edit Cut. Backspace. Paste back the table.