PDA

View Full Version : Hiding Table Rows and Columns



MWE
03-25-2006, 05:39 PM
A recent thread about hiding table rows under certain circumstances prompted a question I have been meaning to ask ... is there a way to hide a row or a column in a Word table? I wish to hide it in the way Excel hides rows or columns, i.e., nothing is visible but the content is still there. My particular need is to add a column to a table and not have the column visible to the "user". The cell will contain a date for the contents of the row (to be compared in the future for possible updates to that row).

I tried setting the column width to zero. That was interesting: Word accepted the request and initially set the column to zero width. Then it thought about that for a second or two and redefined the width of all columns including the one I just set to zero. I suspect that the "autowidth" feature was on, but I can not seem to turn it off.

mdmackillop
03-25-2006, 06:12 PM
I assume you're talking about this question. http://www.vbaexpress.com/forum/showthread.php?t=7562
My first thought was to "hide" the row too, but it doesn't seem to work. Setting the font to hidden seems to be the solution but I don't really like page layouts that change when you hide/unhide the punctuation.
Regards
MD

fumei
03-26-2006, 02:56 AM
You simply can't hide table structure in Word lke you can with Excel.

Word is NOT Excel.

Word is NOT Excel.

Word is NOT Excel.

Word is NOT Excel.

Word is NOT Excel.

Excel is designed around a cellular structure. Word is designed around text. Not layout. Text. It does tables yes, but let's face it, Word does tables like a word processor. This is, IMHO, a good thing, because the bloody thing IS a word processor.

Yes, you can hide table structure in Word, kind of, sort of. But it is not very effective, it certainly is not elegant, and it messes up layout.

If you want to have hidden data in a Word document, there are a number of other ways to do that.

TonyJollans
03-26-2006, 09:08 AM
Word is NOT Excel

Absolutely.

And Excel is not Word. They are two different applications designed for two different purposes. I wish more people understood that and used them appropriately.

MWE
03-26-2006, 09:26 PM
Absolutely.

And Excel is not Word. They are two different applications designed for two different purposes. I wish more people understood that and used them appropriately.I think your response and that of fumei are rather inappropriate and parochial. Sure they are different applications with different basic purposes; but there are lots of cases where the real need is a combination of the features offered by each. In case your guys have missed it, that is part of why this forum exists.

fumei
03-26-2006, 09:46 PM
I think your response and that of fumei are rather inappropriate and parochialOh really.

Interesting.

OK, I can possibly see that as the one who posted, you may think we were being critical, and of course most people who are critiized feel it is inappropriate. However, I do not think we were being particularly critical of you personally. That certainly was not my intention, nor Tony I believe.

But..."parochial"? "Narrowly restricted in scope or outlook". Oh really? Hmmmm. I knew someone who would walk out of his house, open his car, and use the door lock to open his beer. I guess I was being parochial by pointing out that he had the proper tool - a beer opener - on the table. He did not need to go outside to open his beer. But he LIKED to. And yes...it worked. But it is still the wrong tool.

I sorry if you felt offended, as it seemed you were. However, the FACT of the matter is that Word and Excel are different applications, with different purposes, and it is...hmmmmm....(I can think of a number of words) to assume you can just do whatever you want with them. That they should be interchangeable. If I had my way Word would not do ANY numeric calculations at all in tables (for example). The principal cause of bloat in MS products is this persistent, and IMHO deluded, attempt to blur their purposes.

Excel is a speadsheet, it uses a cellular structure, and is designed to work with numbers.

Word is a word processor, it uses text, and is designed to work with.....text.

Apologies again for any offence.

I gotta go. I am working with a Hex editor trying to get Photoshop to calculate my taxes.

mdmackillop
03-27-2006, 12:21 AM
I think things are going off track here. The question, and the other one noted above were regarding temporary hiding of rows and columns. Neither question made mention of doing calculations based on the data in these hidden row/columns or any calculations elsewhere.
I can certainly see valid uses for hiding portions of tables without having to delete them. Word does not offer a simple way of doing this, and much of what we do here is to provide a "facility" that Office does not offer, albeit as a workaround.
To get back to the question, setting fonts to hidden is a way of hiding rows. Is there a way of hiding columns?
Regards
Malcolm

ALe
03-27-2006, 01:16 AM
If you are familiar with Javascript and your project can be in a "internet" format, have a look:
http://www.geocities.com/eric6930/hideshowrows.html

geekgirlau
03-27-2006, 02:05 AM
I have to confess guys that I was a WordPerfect user from way back, and had to be dragged kicking and screaming to use Word at all. Now I find that there are many aspects in Word that I prefer, but unfortunately tables are not one of them.

I constantly find that table formats in Word do what they want to do rather than what you are telling them to do, and I can usually only manage to get them where I want them after much muttering of obscenities aimed at Bill and his team. Column widths in particular make me want to pull my hair out! Tables were a dream by comparison in WordPerfect, and I have to confess that it's the one feature I would love to poach from WP. Almost makes me nostalgic for Reveal Codes!

ALe
03-27-2006, 02:25 AM
Have a look, it's just an example. The idea is to delete a row and store its data in a variable. This variable will write data back with another routine. To be adapted to needs.


Dim val() As String
Dim r As Variant

Sub DeleteRow()
Dim c As Integer
Dim i As Integer
r = 3 'get the row index you want to hide
c = Selection.Tables(1).Columns.Count
ReDim val(1 To c)
For i = 1 To c
val(i) = Selection.Tables(1).Cell(r, i).Range.Text
Next i
Selection.Tables(1).Rows(r).Delete
End Sub
Sub ShowRowAgain()

Selection.Tables(1).Rows.Add beforerow:=Selection.Tables(1).Rows(r)
Dim i As Integer
For i = 1 To Selection.Tables(1).Columns.Count

Selection.Tables(1).Cell(r, i).Range.Text = val(i)

Next i
End Sub

TonyJollans
03-27-2006, 05:12 AM
I think your response and that of fumei are rather inappropriate and parochial.Sorry you feel that way. There was no intent on my part to criticise you but there seem to be many users who think the products are, or should be, interchangeable. Part of what I try to do here, and elsewhere, is help people to make best use of the tools they have. Word does provide simple calculation facilities but it is not a calculation engine. Excel does provide limited text formatting capabilities but it is not a word processor. There are two products for two different purposes and a simple mechanism for embedding one within the other to put the power of both right in front of you.

Word does provide a great many facilities for a great many things - way beyond its remit as a word processor - but hidden columns are not one of them. I have no doubt there is another way to do what you want - but why not an embedded spreadsheet?

fumei
03-27-2006, 05:35 AM
ALe, the object is not to delete rows, and then be able to put in a row again - even with the same text. The object was to hide things, not remove things. Plus it is much easier to do something with rows, rather than columns.

Geekgirlau, ah WP. Yes, I miss those days. The ironic things is...I still think 90% of all users of Word do not use even a small fraction of the features. The truth of the matter is, in terms of what we DO with documents (other than graphic stuff), not much has changed. The truth of the matter is, we could mostly be still using WP for DOS and it would not make a difference.

Although, remember that dinky little "macro" window? Coding in there was a joke. Still, one of the thrills of my document processing career was getting a call from WP in Utah (this was way before they ended up in Corel's expansionist pocket). Someone had been trying to build a macro to do something quite complicated. They had phoned WP (back in the days when WP had superb support) for help. WP worked on it, and said that it could not be done. This person contacted me and challenged me to make it work. It took three weeks, but eventually I made WP jump through the proper hoops. He told WP. WP phoned me to talk about some work, and ....by the way...how did you do it?

WP had its flaws too, but overall it was very well behaved, once you knew it paradigm. Same with Word. Once you grasp what MS means by paragraph, and style...you got a pretty handle on Word.

For example, while we use (and MS uses) the term "cell" for the discrete chunks of a Word table, they are not really cells. At least NOT in the sense of Excel cells. Which is rather my point. Excel is a cellular structure. Word is not. The cells in a Word table can be really thought of as horizontally dispersed bordered paragraphs. The End-of-cell marker is really a paragraph mark, and indeed Word counts them as such. A table is really columns (text columns) that are immediately adjacent. The "cells' are formatted as paragraphs. For this reason they can have styles attached to them.

Even though Cell is ('tis true) an object, and has no style property.

TonyJollans
03-27-2006, 06:03 AM
Although, remember that dinky little "macro" window? Coding in there was a joke.

I remember that :)

I remember uploading macro source to the mainframe and converting double byte characters to single byte - just to be able to get a useful printout of a macro.

fumei
03-27-2006, 06:24 AM
Ah Tony, we ARE old farts.

MWE
03-28-2006, 07:31 PM
My need to hide a column in a particular table is to not clutter up the "appearance" with some tags that will be used for future (automated) updates of that table. The tags are of little value to the user (and will probably just add confusion). I cobbled up a workaround using document properties. It works OK, but is not robust to row deletion and the idea of a hidden cell for each row of the table is very appealing.

As everyone probably knows, although a row's range can have hidden font, a column's range does not support that. One can easily set the relevant cell for each row to hidden font, for example:Sub HideCol2()

Dim I As Long

For I = 1 To Selection.Tables(1).Rows.Count
Selection.Tables(1).Rows(I).Cells(2).Range.Font.Hidden = true
Next I


End Sub but that only hides the text, it does not hide the actual column. It actually does a little more than make the text "not visible". The text is "not there" is the sense tht it would drive any cell size considerations. The row height is now driven by the text in other cells and one can manually set the column width to arbitrarily small values without the row heights jumping around. This approach could work if the column width was also set to something quite small; but explicitly setting the width to "something small" using VBA is either ignored or generates an error message that the value is not valid. :dunno

A tricky way to do this is to play games with borders and hidden fonts. Assume you wish to hide the far right column (col 3 in my example). Remove any border, shading, etc for that column. Then hide the text. The column "disappears". For example:Sub HideCol3()

Dim I As Long

For I = 1 To Selection.Tables(1).Rows.Count
With Selection.Tables(1).Rows(I).Cells(3)
.Range.Font.Hidden = True
.Range = I
End With
Next I

End Sub This approach is dangerous because the user may stumble across the fact that there is some funny business going on just to the right of the table, or may inadvertently delete hidden text.

fumei
03-28-2006, 08:12 PM
This approach is dangerous because the user may stumble across the fact that there is some funny business going on just to the right of the table, or may inadvertently delete hidden text.MWE, this is kind of my point with objecting to trying to do this with Word. Messing around with hidden text in th text body is yucky enough, but doing with Word tables is simply asking for trouble.

Yes, you can do some things with borders and hidden text, but what on earth could be worth the value of doing so? There are probably much, much, better ways of achieving the purposes - of which I am not clear, but I am pretty confident that there are better ways.

Can we mark this a solved...or at least REsolved?

mdmackillop
03-29-2006, 12:15 AM
Hi Gerry,
What's even worse is that rows concealed by the use of hidden text **** up the excellent KB items submitted by our worthy members!
Regards
Malcolm

fumei
03-29-2006, 12:44 AM
Huh? I am sure you have something explicit in mind, but I am damned if I know what the heck you are talking about.

TonyJollans
03-29-2006, 02:32 AM
I seem to be seeing a lot about hidden text these days. It can be useful but, as with all things, overuse is not a good idea.

If we have got KB entries which fail under certain circumstances we should, at the very least, add something to them which states this. Which particular ones are you referring to?

MWE
03-29-2006, 07:02 AM
MWE, this is kind of my point with objecting to trying to do this with Word. Messing around with hidden text in th text body is yucky enough, but doing with Word tables is simply asking for trouble.

Yes, you can do some things with borders and hidden text, but what on earth could be worth the value of doing so? There are probably much, much, better ways of achieving the purposes - of which I am not clear, but I am pretty confident that there are better ways.

Can we mark this a solved...or at least REsolved?given the dialogue started about a KB or something, yes, this should be solved. Solved feature does not seem to be working (at least from my end).

mdmackillop
03-29-2006, 10:42 AM
Huh? I am sure you have something explicit in mind, but I am damned if I know what the heck you are talking about.

Hi Gerry,
I had a quick look at your new cell selection KB. If there is a "hidden row" in the middle of the selection, the final selected area is incorrect.
Regards
Malcolm

fumei
03-29-2006, 11:29 AM
Ah, now I get the reference.

Darn those hidden rows!!!!

fumei
03-29-2006, 11:31 AM
And yes, I will fix my KB entry. Sigh. That means I have to run test for hidden text/rows.

Aaaaarrrrgggghhhhh.

crouz
05-07-2015, 02:37 AM
Oh really.

Interesting.

OK, I can possibly see that as the one who posted, you may think we were being critical, and of course most people who are critiized feel it is inappropriate. However, I do not think we were being particularly critical of you personally. That certainly was not my intention, nor Tony I believe.

But..."parochial"? "Narrowly restricted in scope or outlook". Oh really? Hmmmm. I knew someone who would walk out of his house, open his car, and use the door lock to open his beer. I guess I was being parochial by pointing out that he had the proper tool - a beer opener - on the table. He did not need to go outside to open his beer. But he LIKED to. And yes...it worked. But it is still the wrong tool.

I sorry if you felt offended, as it seemed you were. However, the FACT of the matter is that Word and Excel are different applications, with different purposes, and it is...hmmmmm....(I can think of a number of words) to assume you can just do whatever you want with them. That they should be interchangeable. If I had my way Word would not do ANY numeric calculations at all in tables (for example). The principal cause of bloat in MS products is this persistent, and IMHO deluded, attempt to blur their purposes.

Excel is a speadsheet, it uses a cellular structure, and is designed to work with numbers.

Word is a word processor, it uses text, and is designed to work with.....text.

Apologies again for any offence.

I gotta go. I am working with a Hex editor trying to get Photoshop to calculate my taxes.

I know this post is old and all, but I simply registered on the forum to say: What a whining little bitch. Looks like you are the one incapable of taking in criticism.

ihightower
02-15-2016, 09:45 PM
A recent thread about hiding table rows under certain circumstances prompted a question I have been meaning to ask ... is there a way to hide a row or a column in a Word table? I wish to hide it in the way Excel hides rows or columns, i.e., nothing is visible but the content is still there. My particular need is to add a column to a table and not have the column visible to the "user". The cell will contain a date for the contents of the row (to be compared in the future for possible updates to that row).

I tried setting the column width to zero. That was interesting: Word accepted the request and initially set the column to zero width. Then it thought about that for a second or two and redefined the width of all columns including the one I just set to zero. I suspect that the "autowidth" feature was on, but I can not seem to turn it off.


You can hide column.. with this simple vba example..
step 1.. select the column you want to hide...
then run the vba code.. the column will be come small... you can extend it to remove any borders.

This is basically a toggle... it hides if it is shown... if it is shown.... it hides...
just keep the column really small... for the selection purposes.


Sub HideColumnInWord()
'
' Macro2 Macro
'
'
If Selection.Font.Hidden = True Then
Selection.Font.Hidden = False
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(20)
Else
Selection.Font.Hidden = True
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(0)
End If




End Sub