PDA

View Full Version : Solved: Using VBA To Hide A Table



Stygmata
02-18-2008, 09:14 AM
Hi Guys

I am a newbie to the forums and a newbie to VBA, so any help is greatly appreciated.

I have a table containing form fields, drop down boxes etc... which users fill in, then bookmark reference points throughout a document are filled in dependent on what's entered in these. (I hope that makes sense!).

I need to hide this table and it's contents once the reference fields have been updated. Is there any way to do this please?

I am using Word 2000.

Many thanks

Styg

fumei
02-18-2008, 12:05 PM
Why? What is the business case for hiding the table? What does that mean actually? Do you want to "hide" it, but be able to bring it back? if so...again...WHY?

Does it mean, take it away? Let the user do whatever in the table, and then once things are set/updated, get rid of it?

WHY do you need to hide the table?

Tinbendr
02-18-2008, 07:37 PM
I do the same thing for a local form in our office.

This toggles the table on and off.


Sub HideTable()
Dim aDoc As Document
Dim aTable As Table
Set aDoc = ActiveDocument
Set aTable = aDoc.Tables(1)
If aTable.Range.Font.Hidden Then
aTable.Range.Font.Hidden = False
Else
aTable.Range.Font.Hidden = True
End If

End Sub

Stygmata
02-19-2008, 05:23 AM
Why? What is the business case for hiding the table? What does that mean actually? Do you want to "hide" it, but be able to bring it back? if so...again...WHY?

Does it mean, take it away? Let the user do whatever in the table, and then once things are set/updated, get rid of it?

WHY do you need to hide the table?
I need to hide the table because the completed document needs to be uploaded on to various websites as part of a business proposal. I do not want to show the customers that this is not a bespoke document but is generated from a template.
Are you suggesting that the table can be removed (without removing the links to the references in the document) then?

Thanks!

Styg

Stygmata
02-19-2008, 05:24 AM
I do the same thing for a local form in our office.

This toggles the table on and off.


Sub HideTable()
Dim aDoc As Document
Dim aTable As Table
Set aDoc = ActiveDocument
Set aTable = aDoc.Tables(1)
If aTable.Range.Font.Hidden Then
aTable.Range.Font.Hidden = False
Else
aTable.Range.Font.Hidden = True
End If

End Sub


Many thanks for this! I will give it a try.

Styg

fumei
02-19-2008, 10:37 AM
"Are you suggesting that the table can be removed (without removing the links to the references in the document) then?"

Well,

1. any table can be removed.
2. I do not know what you mean by "links to the references in the document"

From your OP:

"which users fill in, then bookmark reference points throughout a document are filled in dependent on what's entered in these."

If those bookmarks are filled in...then they are filled in. There are no references, or links. Not unless you create references or links.

If type "Yadda" into a text formfield, and that Result ("Yadda") is then put into bookmark "Yipeeee", then if you do not need that text formfield anymore, sure you could delete it. Whether it is in a table, or the table it is in.

Sounds to me like this may call for a userform.

Stygmata
02-20-2008, 04:42 AM
Thanks Fumei

I suspect that you may be correct in that it is a user form that would prove more useful on this occasion!

I'm going to have a play around with a user form and see if that serves me better.

Thanks again

Styg