Log in

View Full Version : Solved: Some table questions



TrippyTom
01-22-2008, 09:53 AM
I have some generic questions because I'm not familiar with Word's object model as much as I am with PowerPoint. Here they are:

1) Is there a way (via VBA) to know if selected text is inside a table?

2) Does there have to be text in a cell to change that cells borders or font color (like in PowerPoint)?

fumei
01-23-2008, 03:20 AM
I am trying to be careful with my words, and tone, so I am restricting myself to only answering the actual questions.

1. Yes. Selection.Information(wdWithInTable). It is Boolean.

2. No. A cell is an object. Its attributes are what they are, whether there is text within it, or not.

TrippyTom
01-23-2008, 09:42 AM
Thanks Fumei. That helps.

I found that, in PowerPoint, it wouldn't let me change borders in a table unless text was in a cell - which I found quite odd, because my thinking was the same as yours. It's an object. It shouldn't matter if there's text or not. But oddly enough, it just wouldn't work unless I had text in the cell first, so I added a space in any empty cell before modifying the cell.

I was just wondering if the same odd behaviour was in Word too. I'm glad it's not.

fumei
01-23-2008, 11:10 AM
I am decidely not a PowerPoint guy. That sounds very odd to me, but obviously it IS a part of the PP Object Model, and is NOT a part of the Word Object Model.

Although.....I can sort of see why.

In PP, I assume that the cell in a "table" is actually a Shape object.

In Word that cell is not a Shape. It is a Cell. A distinct object.

The cell in a table in PP is part of a Shape???

Why that would translate into requiring text...shrug...no idea. It does seem odd that you would have to have at least " " - a space - in order to modify characteristics.

Whatever. It is Microsoft, and both (PP and Word) are separate teams. What can I say?

TrippyTom
01-23-2008, 11:26 AM
Heh.. you would be shocked if you saw my company's current template for Word. It's terrible!

They have 52 useless styles for various bullets and I keep trying to tell them how to fix it. I even setup my version of how it should be setup but they don't seem to be listening.

That's what prompted my question. They have separate styles for text in a table and separate styles for font sizes! I couldn't believe it when they released that rediculous template.

Setup properly, we could reduce those 52 styles to 4.

TrippyTom
01-23-2008, 11:33 AM
... and you were right. If you "ungroup" a table in PPT it converts everything to separate shapes (the borders become lines, cells become text boxes). Because of this, it can't be converted back to a table as we would normally think of it.

I guess that's the reason for the strange behaviour I was experiencing.

fumei
01-23-2008, 11:36 AM
"Setup properly, we could reduce those 52 styles to 4."

Hoohoo!!! Go for it! Yeah!

I have no doubt. No doubt at all.

"I even setup my version of how it should be setup but they don't seem to be listening."

I feel your pain. Been there.