1
votes

I have a document that is roughly 200 pages and is essentially a list of test procedures for a specific software. Now this document has certain parts to it the pertain to different versions of the software and these parts are mixed in so their not nicely formatted in a specific order. What I would like to do is Be able to hide the parts of the document that are not needed when testing a different version. I know MS word has a font option to hide text but I would like to be able to setup up a button/hypertext link/macro that will easily hide the unneeded sections. Is this possible and how would I do it? I've started experimenting with VBA script to design my own macro but have only found a way to hide one part per shortcut hit. Is there a way to do this so all parts are effected simultaneously?

EDIT:

The document is organized like this

Version 1
   Test Option button
/
Version 2
   Test Option button
       Check that Sample button is disabled
/
Version 1
   Test Save button
/
Version 3 
   Test Save to USB button

/

So as you can see it's completely unorganized the code I currently have for one macro really doesn't work because instead of selecting between the two point I specify it selects the whole document.

Sub TextSelectTest()
'
' TextSelectTest Macro
' Base Test
'
With Selection.Find
    .Text = "Version1"
    .Forward = False
    .MatchWildcards = False
    .Wrap = wdFindStop
    .Execute
End With
Selection.Extend
With Selection.Find
    .Text = "/"
    .Forward = True
    .Execute
    .Text = ""
End With
Selection.Extend
With Selection.Font
    .Hidden = True
End With
End Sub
1
First, show the code you have. Second, how is the document organised, if you want to hide 'section of version A' all that information are divided into real word section, tables, 'pages'. Tell us more which way the document is prepared. You could upload a sample somewhere.Kazimierz Jawor
okay I updated the original post with the info you requested, I couldn't really upload the the actual file cause it contains a lot of screen shots a reference but hopefully that little outline should give you an ideauser1704863

1 Answers

1
votes

I don't think hiding font is most professional solution as the result is visible only for printing. But that could be the easiest in this situation especially you suggested it.

First step: set sections in your documents. It's quite easy and should be done ones in Word app. You will need to insert as many section separation marks as many parts of the document you need to manage. We will need to know which section should be/shouldn't be part of each Manual but I'll back to that later.

Second steps: Than you will need the following subroutine which will 'hide' all sections and than show appropriate ones:

Sub HideUnhide_Document_Section(secIndex As Variant)

Dim Doc As Document
Set Doc = ActiveDocument

Dim secDoc As Variant

'to hide all section first, by iteration 
For Each secDoc In Doc.Sections
    secDoc.Range.Font.Hidden = True
Next secDoc
    'alternatively we could hide whole content without iteration:
    'secDoc.Content.Font.Hidden = True

'to un-hide chosen sections
For Each secDoc In secIndex
    Doc.Sections(secDoc).Range.Font.Hidden = False
Next secDoc

End Sub

And to manage your hiding process I would propose the following code:

Sub Call_Hide()

Dim arrVersion1 As Variant
    'put all sections for appropriate version
    arrVersion1 = Array(1, 3)

    'to unhide
    HideUnhide_Document_Section arrVersion1
End Sub

You could either prepare similar separate subroutine for each version or parametrize that one. It that second situation it will have to have separate arrays (arrVarsionX) for each Version of your manuals.