Hi : )

I am build some kinda of reports and I have some information I would like to
let the user show if he/she want to see or not. If he/she want to see, he/she
will click in image component. But I would like to use the 'same' (visually
talkin) component to hide the data. This is a sample:

Private Sub Image1_Click()
Selection.GoTo What:=wdGoToBookmark, Name:="interfaces_lista"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Tables(1).Select
With Selection.Tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleDashSmallGap
.LineWidth = wdLineWidth050pt
.Color = 14540253
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleDashSmallGap
.LineWidth = wdLineWidth050pt
.Color = 14540253
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleDashSmallGap
.LineWidth = wdLineWidth050pt
.Color = 14540253
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleDashSmallGap
.LineWidth = wdLineWidth050pt
.Color = 14540253
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleDashSmallGap
.LineWidth = wdLineWidth050pt
.Color = 14540253
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleDashSmallGap
.LineWidth = wdLineWidth050pt
.Color = 14540253
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleDashSmallGap
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = 14540253
End With

Selection.Tables(1).Rows.Height = CentimetersToPoints(0.6)
Selection.Font.Color = wdColorGray80
Selection.Font.Size = 8
Selection.GoTo What:=wdGoToBookmark, Name:="interfaces"
End Sub

So, when I click in the icon, a table shows up with some data, and to 'hide'
it, I use:

Sub interfaces_compact()
Selection.GoTo What:=wdGoToBookmark, Name:="interfaces_lista"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Tables(1).Select
With Selection.Tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorWhite
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorWhite
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorWhite
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorWhite
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorWhite
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorWhite
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorWhite
End With
Selection.Tables(1).Rows.Height = CentimetersToPoints(0#)
Selection.Font.Color = wdColorWhite
Selection.Font.Size = 1
Selection.GoTo What:=wdGoToBookmark, Name:="interfaces"
End Sub

So, there is some way to use the control to show up the table (code 1), and
if the table is show and I click in the control again it hides (code 2)?

I tried to hide the component... but I didn´t get sucess.

Thanks for any info.

RE: Hide and show components by Patrike

Patrike
Tue Jan 08 10:34:02 PST 2008

Well, it could be simplified to:

How to hide/show a table?

I found this code:

Selection.Tables(1).Rows(3).Range.Font.Hidden = True

but this isn´t working.

and if I click in the button it show the table and if I click again it hides
the table...

sorry for the biiig code in the last post.

thanks again.

Re: Hide and show components by David

David
Tue Jan 08 11:28:02 PST 2008

Did you want to hide the entire table?

http://tinyurl.com/2ybbjn

Is each area you want them to view in a seperate table?

You might put each table in a section and hide that.

You might add a activex control to the document and then activate
userforms to show the information.

Re: Hide and show components by Patrike

Patrike
Wed Jan 09 05:26:03 PST 2008

Hi David,

Thanks for the reply..

I am trying:

Sub HideTableA()
Selection.Tables(1).Select
With Selection.Font
.Hidden = True
End With
End Sub

It just select the table but do not hide it... I am using Word 2002.

Re: Hide and show components by David

David
Wed Jan 09 07:51:07 PST 2008

I'm using 2003 and your example works for me.

I don't know what else to suggest.

Put a control break in your code and step though it to make sure it's
functioning properly.

Re: Hide and show components by Patrike

Patrike
Wed Jan 09 09:03:01 PST 2008

Thanks david...

I tried with word 2003 and I didn´t get it to work to...
can u please share a word document?

thanks a lot...

Re: Hide and show components by David

David
Wed Jan 09 10:09:43 PST 2008

Just start with a new document. Create any table from the menu and
try the code. If it works, start adding the other componets to the
document until you have a problem.