Friday, December 19, 2008

Hidden Text in Word

This post explains how to collapse multiple sections in a word doc.

There may come a time when you need to collapse sections of a word doc based on a checkbox. The sample form I'm using looks like this:

To create this form:

1. Create a new word doc and add a checkbox.

2. Type some text under the text box.

3. Select the area you wish to hide and add a bookmark: Insert->Bookmark. The Bookmark dialog will appear. Type "Section 1" as bookmark name and close.

4. Repeat the process two more times.

What we've done is create "Enclosing Bookmarks" around some text. There are actually two types of bookmarks. These are:

1) Placeholder Bookmarks which look like a beam.

2) Enclosing Bookmarks that will show up as graphics.

You can see these book marks by going to Tools->Options->Display Bookmarks.

(Bookmark indicators in Red)

Now for hooking up the checkboxes.
The Checkboxes need to call a function. So, first we have to write the function. The code should look like so:

Public Sub Hideit()

'unprotect the document
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If

ActiveDocument.ActiveWindow.View.ShowHiddenText = False

'Get the range of the bookmark.
Dim rng As RangeSet rng = ActiveDocument.Bookmarks("Section1").Range

If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then

rng.Font.Hidden = 0
rng.Font.Hidden = 1
End If

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Now in the Checkbox, select this function and your
done! Additional Info here:

Happy Coding!


Wednesday, December 03, 2008

Line Ring Selection Algorithm

I'm thinking about adding a tool that will select a ring of lines.
Here is an example of a ring you want to select.

Okay, what I've come up so far is something pretty simple.
1. Copy the target face.
2. Check to see if the selected line is an edge.
3a. Yes, calculate all the edges that are attached to the selected edge and select. END
3b. No, remove all polys that have edges. goto 2.

This image shows how it would work on the example.

I know there are some exceptions. It seems simple enough. I'll let you know how it works.

Happy Coding!