Microsoft Word 2003 and WordML (How to Show/Hide Content in a Document)?

All,
How to show/hide specific sections(assume a paragraph) of a document by checking/unchecking a checkbox (I'm using Word 2003)

How to lock/unlock a specific section(assume a paragraph) of a document based on (Checking / Unchecking)check boxes
Can we achieve this without using VBA in Microsfot Word 2003

If at all i need to use VBA, as i'm not familiar with VBA, can anybody provide the sample code to show/hide parts(assume if i check the checkbox, i need to see a paragraph in the document, by unchecking the checkbox it should be hided) of the document using check boxes.

Clear instruction with sample code (if i need to use VBA) would be greatly appreciated.

Thanks,
Maruthi.


Answer this question

Microsoft Word 2003 and WordML (How to Show/Hide Content in a Document)?

  • chid

    In general terms, you should be able to do this in a Word document, without needing to put a VBA project in the document. VSTO provides a means to work with ActiveX controls embedded in the document, such as a checkbox. Mike Walker gave you the basic code that hides/unhides text in a Word document.

    As for protecting/unprotecting: what type of protection do you have in mind Protecting as a form The "read-only" type of protection provided in Word 2003 something else

    -- Cindy Meister



  • prabhat shrestha

    Hi Maruthi,

    As Mike mentioned, you can hide the font of a selection, or range by setting the Hidden property to True. If you've added a checkbox  to a VSTO Word solution, you can try the following code. This code hides the font of the first paragraph in the document; you can change it to work with a specific range:

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

        If Me.CheckBox1.Checked Then
           
    Me.Paragraphs(1).Range.Font.Hidden = True
       
    Else
           
    Me.Paragraphs(1).Range.Font.Hidden = False
       
    End If

    End Sub

    I hope this helps.

    Kathleen McGrath



  • Gatecrasher

    My intention is to use check box, by means of which i would like to show/hide content.

    If i check the checkbox the content ( assume a paragrpah of text ) should be displayed, when i uncheck the checkbox it should be hided. This is my primary intention. By the way i'm using Word 2003.

    Can you provide me a resolution for this .

    Thanks,

    Maruthi.


  • lekem

    Are you thinking of using Hidden text What are you intending to happen on the Print happening. Below is a sample to change a block of text to be hidden.

    With Selection.Font
    .Hidden = True
    End With

    This will now use Edit Properties to make hidden text visible or not in the UI or not.

    Regards



  • Microsoft Word 2003 and WordML (How to Show/Hide Content in a Document)?