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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding sections within a Form in Word....using a check-box control 1

Status
Not open for further replies.

mbr501

IS-IT--Management
Feb 19, 2001
21
0
0
US
I have a long Form in Word that has various sections to it. At the top of my form, I have a series of check boxes that specify various departments within my organization.

I want to allow a user to select one or more of the check boxes, which would then invoke the respective sections of the form and supress the sections that do not apply. Basically, I'm trying to prevent from having one super long form that the user would need to scroll through to see only the areas they need to fill out. By having the check box up front, it would show only those areas that are applicable based on that check box value.

Any examples would be appreciated.
 
Interesting.

I am not sure what you mean exactly by "invoke", and "supress". When you say "show only those areas" applicable to the checkbox, do you mean remove the other sections? It is possible to do that. The only other thing would be to make the other sections hidden font, and then make sure that Show/Hide is off. But it would be very easy for a user to turn it back on.

Could you clarify exactly what you want to happen? It would not be hard to have it so checking a box would take the user to a specific section. This would bypass scrolling. It would simply go there.

So is it a navigation issue, or a structural one?

Gerry
 
Hi Gerry,

Thank you for your reply....helpful.

Let me clarify - yes, it is more of a navigation issue. Here's the example.....I have a new hire checklist that I've built. There are, however, several tables within it, that are only applicable to certain managers based on the teams they run. There is also a section (the top section) that is applicable for all managers (name, position, start date, etc..).

What I want to do is when a manager opens up the template, they would check their 'department' based on who they are. At that point Word would only show those specific sections which are applicable to their respective departments along with, of course, the top section which is indicative to all managers like I explained above. So if I'm a manager for the Edge team, when I open the form, I click on 'Edge'. This then only shows me the sections in the form that are applicable for a new hire that will work in the 'Edge' team. Does that help clarify?

Since it's only managers that will be using this, I'm not as concerned about strict security with enabling/disabling hide sections, but the 'cleaner' we can make this so that little maintenance is needed once the form is 'live' the better of course....if you could please provide any examples within Word on how this would work, I would appreciate it. I guess I'm thinking somehow I need to name my tables or sections, then tie those back to the specific checkbox so that when the user clicks their respective 'department' check box, it only shows those respective tables that are named accordingly...or something like that.

Thank you very much.
 
I'd do all of the typing on VBA user forms, then build whatever document you need based on that input.

Otherwise, judicious use of bookmarks and macrobuttons should be able to get you where you want to go.
 
In a proper world mintjulep is completely correct. Userforms would in fact be the better route.

First off. When you mention template, you state "opens the template". I hope that is not the case. I hope you are using a template file, and created a new document based on that template - not opening it.

Second, you state it is more of a navigational issue, yet you still ask about hiding stuff. Hiding stuff is not navigation. Navigation is moving around through a document, which is not what you are asking about. So, really, it is NOT a navigational issue. You want to have a document that only has visible elements that reflect specific criteria.

Therefore it is not a navigational issue, it is, at the bottom line, a structural one. Following that thought, a well designed template can be used to create documents whose structure is based on initial criteria.

Hiding stuff in Word is possible, but it NOT elegant or very efficient. In fact, I rather discourage it. Far better would be to design variable structure into the template.

So where does that leave you? Here. Have the section applicable to all in its own distinct section. It appears you have that already. Good.

Make any sections that are discrete into their own section. This is one route. It is not strictly needed if you use, again as mintjulep suggests, a judicious use of bookmarks, which is what I am also suggesting.

The point being is that if you isolate, by structure, the chunks applicable to choices made in the first section. Then while the template (i.e. the .DOT) file has ALL chunks, once the user makes the choice in the first section, the logic derived from that will remove all chunks not applicable.

Do you see why I asked about removing chunks. You did not answer, but IMHO that is the way to go. Although of course I do not know your document. Hiding stuff is kludgey at best in Word. "Showing only" stuff is not what Word does best, or even well. Besides, it is not very good design.

Good design will have all choices in the template, but only the chosen chunks in the document.

Now, you CAN do this with the first section being in the document, and make the choices there. However, I would prefer to use a UserForm to get the choices from the users. It is more efficient I think, cleaner in the document, and IMHO, more professional looking. A nice well designed dialog form, with lovely choices and buttons. User clicks OK, badda-bing, badda-boom....all sections not applicable to the choice....oudda there! The only thing left is the chunks applicable to the choice.

How do you do that? You can take your current template (and again, hopefully a .DOT file), select each chunks and make it a bookmark. You can select as much text/tables as you like. Select it, and Insert > Bookmark, and give it a name. Say...FinanceManager. Then....WarehouseManager. Whatever. OK, so now they are bookmarked. The chunks.

Using existing checkboxes:

Make an OnExit macro for the checkboxes. Again, good design would use ONE macro for all checkboxes. However, this means well named checkboxes, and I can not assume that. In any case, the OnExit macro for say checkbox FinanceManager would be something like:
Code:
Sub MakeChunks()
Dim strFFName As String
Dim oBM As Bookmark
strFFName = Selection.FormFields(1).Name
ActiveDocument.Unprotect Password:=""
If ActiveDocument.FormFields(strFFName).Result = True Then
    For Each oBM In ActiveDocument.Bookmarks()
        If oBM.Name <> strFFName Then
            oBM.Select
            Selection.Delete
        End If
    Next
End If
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True, Password:=""
End Sub
The above works well if there IS careful naming of both your formfields, AND your bookmarks.

The reason I would prefer to user a UserForm is that it is cleaner to have the logic in the form, rather than in the document itself. Plus, you do not have to deal with formfields - although I love formfields.

Hopefully, this gives you an idea of a (possibly) better design. If you want to get an idea of what I am talking about I could send a file.

Gerry
 
Gerry, my previous post appears not to have worked, anyway, the explanation to mrb501 was superb, its taken me the last week to find this how-to, I can't find anything else that explains this.

I have been trying to do the same thing as mrb501. My knowledge is in databases and webtechs so Word isn't my best understood app.

Anyway, I notice that you have said you have a file that would help, would it be possible I could have a copy of this file.

Thanks in advance...

Steve

 
Send an email to me, and we can discuss off-line - well, off-line to here anyway. Posting viable (scam-able) addresses is not permitted. You can reach me at: my handle at telus dot net.

I did make up a file when this thread was current. Not sure if I still have it, but it would not be difficult to whip one up again. Email me and we can quickly discuss how complicated a document you want to see. I am here for...ummm, four days, then I will be out of town for three weeks.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top