Aligning table cell contents based on style

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello.

I'm trying to align all table cell contents to the bottom of the cell if
they are "Table Heading Style".

I've written the following macro to do this.

Sub AlignTables()
'Aligns table headings
Dim Table, aRow, aCell, myRange
For Each Table In ActiveDocument.Tables
For Each aRow In Table.Rows
For Each aCell In aRow.Cells
myRange = aCell
If myRange.Style = "Table Heading" Then
aCell.VerticalAlignment = wdAlignVerticalBottom
End If
Next aCell
Next aRow
Next Table
End Sub


This doesn't work though. I get an error - "Object variable or With block
variable not set".

Any ideas how I can get this working. Thanks in advance.

Dave.
.



Relevant Pages

  • Re: Can I automagically number lines in a table in Word 2003?
    ... A SEQ field will not have a period? ... With the cursor in cell A1, the following macro will number the cells in a ... column and right align the result. ... since AUTONUMLGL is deprecated, provided ...
    (microsoft.public.word.docmanagement)
  • Re: HList with image and text - alignment problem
    ... "Martin Herrmann" wrote in message ... but the picture is centered inside the cell. ... I managed successfully to display a graphic above a text inside a cell ... Additionally I managed to align the text to the left side. ...
    (comp.lang.perl.tk)
  • Re: Positioning tables
    ... or in an adjacent cell. ... Doug Robbins - Word MVP ... I need to nudge the nested table up or down to align with my ...
    (microsoft.public.word.tables)
  • Re: Default character at beginning of cell
    ... Could you use a help column? ... right align it, now left align B2 ... the other option would be an event macro that will add a character when you ... > given cell before the information that a user types in? ...
    (microsoft.public.excel)
  • Re: modifiying Excel Cells from VB
    ... i need to align horizontal text to the top of the cell ... i.e. if the cell is double height, as standard the text is aligned to the ... >>and puts it into an excel spreadsheet, ... >>Now what i want to do is setup wraptext on my column, ...
    (microsoft.public.dotnet.languages.vb)