PDA

View Full Version : Userform Wizard, Empty Field Function



liamwhan
03-27-2011, 04:18 PM
Hi All,

Before we start some info:
Application: MS Word 2003
Ver: SP2 (11.6568.6568)

Apologies for the long question but I'm really unsure as to how to properly phrase it so I'm going to do my best.

I have created a Wizard to enable employees at my workplace to complete a Form digitally that has, in the past, been completed by hand.

I have used Bookmarks (labled: 'Text1' - 'Text12', for the 12 Text Fields and a Userform (run with an autonew Macro on open), also Bookmarks (labelled: 'Check1' - 'Check13') for the 13 check boxes which, if TRUE place a ticked checkbox character in the appropriate spot and if FALSE place an empty checkbox in the spot.

My problem is: The form would be perfect for distribution to the employees IF there was an option to fill it out by Hand.

In other words I need a function that, in the event that the text fields are empty, replaces the empy spaces on the form with a series of underscores "___________________" for people to write on. In order to do this I'm guessing that there might be an IF THEN function? but I know almost nothing about Vba and what Ive created so far I have pieced together from forums and tutorial sites.

Does anyone know if there is such a function or a work around?

Thank you in advance for any help you can give! The, undoubtedly clunky and inefficent, code I have used is below:

For the Text Fields:

Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("Text1").Range _
.InsertBefore TextBox1
.Bookmarks("Text2").Range _
.InsertBefore TextBox2
.Bookmarks("Text3").Range _
.InsertBefore TextBox3
.Bookmarks("Text4").Range _
.InsertBefore TextBox4
.Bookmarks("Text5").Range _
.InsertBefore TextBox5
.Bookmarks("Text6").Range _
.InsertBefore TextBox6
.Bookmarks("Text7").Range _
.InsertBefore TextBox7
.Bookmarks("Text8").Range _
.InsertBefore TextBox8
.Bookmarks("Text9").Range _
.InsertBefore TextBox9
.Bookmarks("Text10").Range _
.InsertBefore TextBox10
.Bookmarks("Text11").Range _
.InsertBefore TextBox11
.Bookmarks("Text12").Range _
.InsertBefore TextBox12
End With

For the Checkboxes:

If CheckBox1.Value = True Then
ActiveDocument.Bookmarks("Check1").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox2.Value = True Then
ActiveDocument.Bookmarks("Check2").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox3.Value = True Then
ActiveDocument.Bookmarks("Check3").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox4.Value = True Then
ActiveDocument.Bookmarks("Check4").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox5.Value = True Then
ActiveDocument.Bookmarks("Check5").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox6.Value = True Then
ActiveDocument.Bookmarks("Check6").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox7.Value = True Then
ActiveDocument.Bookmarks("Check7").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox8.Value = True Then
ActiveDocument.Bookmarks("Check8").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox8.Value = True Then
ActiveDocument.Bookmarks("Check8").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox9.Value = True Then
ActiveDocument.Bookmarks("Check9").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox10.Value = True Then
ActiveDocument.Bookmarks("Check10").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox11.Value = True Then
ActiveDocument.Bookmarks("Check11").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox12.Value = True Then
ActiveDocument.Bookmarks("Check12").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If
If CheckBox13.Value = True Then
ActiveDocument.Bookmarks("Check13").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=254, Unicode _
:=True
End If

If CheckBox1.Value = False Then
ActiveDocument.Bookmarks("Check1").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox2.Value = False Then
ActiveDocument.Bookmarks("Check2").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox3.Value = False Then
ActiveDocument.Bookmarks("Check3").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox4.Value = False Then
ActiveDocument.Bookmarks("Check4").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox5.Value = False Then
ActiveDocument.Bookmarks("Check5").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox6.Value = False Then
ActiveDocument.Bookmarks("Check6").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
UserForm1.Hide
If CheckBox7.Value = False Then
ActiveDocument.Bookmarks("Check7").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox8.Value = False Then
ActiveDocument.Bookmarks("Check8").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox9.Value = False Then
ActiveDocument.Bookmarks("Check9").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox10.Value = False Then
ActiveDocument.Bookmarks("Check10").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox11.Value = False Then
ActiveDocument.Bookmarks("Check11").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox12.Value = False Then
ActiveDocument.Bookmarks("Check12").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
If CheckBox13.Value = False Then
ActiveDocument.Bookmarks("Check13").Range.InsertSymbol _
Font:="Wingdings", CharacterNumber:=168, Unicode _
:=True
End If
End Sub