Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word table border puzzle

Status
Not open for further replies.

RobBroekhuis

Technical User
Oct 15, 2001
1,971
US
Hi all,
My Word object model knowledge is sketchy, and I can't figure this one out. I have a table in Word (a document I didn't create myself) with a variety of line styles along the left and right borders. I'm trying to query the line style along the left of the table. When I put the cursor into a first-column cell with a solid line along its left edge, and query in the immediate window:

?selection.cells(1).borders(wdBorderLeft).linestyle
0

(0 is wdLineStyleNone)
similarly, if I try instead of cells(1) to use rows(1) or tables(1), I get the same answer. Is there a different property that sets some of the line styles? The value for .borders(wdBorderRight) is correct, by the way.
Any ideas?



Rob
[flowerface]
 
Hi Rob,

Long time, no see [smile]

There is no easy way I know - you COULD do it if you really tried with Drawing objects but you would have to have time on your hands. But if you have a variety of styles it sounds like it was done by someone with time to play, so you never know.

Just to double-check, if you select the cell and Format > Borders & Shading, what does it show?

Enjoy,
Tony
 
Some background - I'm converting a Word document created by exporting and reformatting a web page. As is, it has the ugly double-line formatting typical of html tables. If I go in manually, and change "cell spacing" to 0 in table properties, all is well. However, when I try to automate that:

for each t in activedocument.tables
t.spacing=0
next t

the table is modified in different ways as well: all of the borders along the right-hand side of the table disappear. I've no idea why. I'm now trying to fix that problem, but I can't just put a uniform border along the right side - whether there should be a border along the right depends on whether there is a border along the left. And I can't seem to find a way to figure out if there is one. After some more detective work, I've found that I can accurately detect borders in the table interior, but borders along the exterior always have Linestyle=0. Bah!


Rob
[flowerface]
 
Hi Rob,

I went and grabbed a random web page with a table as you describe and it is an absolute horror.

The table seemed to be connected to an Inline Shape which is what had the exterior lines. I have no idea of the best way to go about dealing with it. I wish you well!!

If I get some time later I might have a bit more of a play.

Enjoy,
Tony
 
I actually found out a little more about this problem (TIP: when you have a tough problem, it pays to check out archives of newsgroups. I usually go to which takes me to Google's service).
Turns out that my problem is a documented inadequacy of Word VBA - there is no way of disabling cell spacing through VBA. There is, however, also a documented work-around: instead of setting the spacing to 0, set it to -1. It's ridiculous, but it works.


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top