Need help with border removal in a cell

X

Xavier

Hi,

I've been trying for hours to remove the bottom border of a cell in a Word
table. I must be missing something obvious, so I hope someone can help me:

The code I am using (from MS Access VBA) is the following:

With doc.Tables.Item(1)

' removing stuff that works

With .Cell(tbl.Rows.Count - 2, 4).Range
.Text = "Here !"
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders.Enable = True
End With

' removing other stuff that works as well

End With

For that particular cell, I would like to have no bottom border drawn. I am
sure I am referencing the right cell because I am putting the "Here !" text
and it appears as expected.
I also checked that other contiguous cells formatting do not interfere with
this one (e.g. activating the top border of the cell located under the one
for which I want to remove the bootom border).

Any help would be appreciated.

Xavier
 
J

Jonathan West

Hi Xavier


The problem is this line

With .Cell(tbl.Rows.Count - 2, 4).Range

This is applying the following lines to the Range object which marks the
text in the cell, not the cell itself. Unfortunately, it is the Cell that
has the borders, not the range

You need to change that block so that it reads as follows

With .Cell(tbl.Rows.Count - 2, 4)
.Range.Text = "Here !"
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders.Enable = True
End With

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
X

Xavier

Hi Jonathan,

Thanks for your help. Following your advice, I changed my code to

With .Cell(tbl.Rows.Count - 2, 4)
.Range.Text = "Here !"
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
End With

And it now works as I expected it. Note that I had to remove the
".Borders.enable = True" line because it seems to act as an on/off switch
for the whole cell regardless of any particular setting that might have been
applied before.

Thanks again !!!

Xavier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top