View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Question to Smarter Folks than I

SgtMajor,

The code you could you would look something like this:

Option Explicit
Private mstrFF As String

'Use this to set up the checkboxes
Public Sub SetupMacros()
Dim ffItem As Word.FormField
For Each ffItem In ActiveDocument.FormFields
If ffItem.Type = wdFieldFormDropDown Then
With ffItem.DropDown.ListEntries
.Clear
.Add " "
.Add "Y"
.Add "N"
.Add "N/A"
End With
End If
ffItem.EntryMacro = "AOnEntry"
ffItem.ExitMacro = "AOnExit"
Next
End Sub

Public Sub AOnExit()
With GetCurrentFF
If .DropDown.Value = 0 Then
MsgBox "You can't leave field: " & .Name & " blank"
mstrFF = GetCurrentFF.Name
End If
End With
End Sub

Public Sub AOnEntry()
Dim strCurrentFF As String
If LenB(mstrFF) 0 Then
ActiveDocument.FormFields(mstrFF).Select
mstrFF = vbNullString
End If
End Sub

Private Function GetCurrentFF() As Word.FormField
With Selection
If .FormFields.Count = 1 Then
' CheckBox or DropDown
Set GetCurrentFF = .FormFields(1)
ElseIf .FormFields.Count = 0 And .Bookmarks.Count 0 Then
Set GetCurrentFF = ActiveDocument.FormFields _
(.Bookmarks(.Bookmarks.Count).Name)
End If
End With
End Function

You could intercept Print and Save and run this as a final check of all
fields

Sub CheckAll()
Dim ffItem As Word.FormField
For Each ffItem In ActiveDocument.FormFields
If ffItem.Type = wdFieldFormDropDown Then
If ffItem.DropDown.Value = 0 Then
ffItem.Select
MsgBox "You must fill in each ckecklist item."
Exit Sub
End If
End If
Next
End Sub

Post back if you need more help.

1SgtMajor wrote:
My company uses a checklist in MS Word with drop down boxes after each
question with either a "N", "Y", or "NA".

It seems everyone always misses at least one of the drop down boxes
which creates a problem.

Is there some way to create a checklist in "Word" preferably will use
anything right about now...(Smile)..... that the form would NOT be
completed until each box is properly selected with a response?--

Any help would be appreciated.
Steven R.
SgtMajor, USMC (Retired)


--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

Arrogance is a weed that grows mostly on a dunghill (Arabic proverb)