Search for an Unchecked Checkbox

D

Debra Ann

Microsoft Word 2003

I need to create a macro that searches the document for checkboxes that are
not checked. This document is not a locked down form. What is the code for
searching for an unchecked checkbox?

thanks,
 
H

Helmut Weber

Hi Debra,

Sub Makro2()
Dim oFld As FormField
For Each oFld In ActiveDocument.FormFields
If oFld.Type = wdFieldFormCheckBox Then
If oFld.Result = False Then
oFld.Select
Stop
End If
End If
Next
End Sub
 
D

Debra Ann

Helmut,

That works great except for the "Stop". When it gets to the stop, it opens
up the VB code. A user will not know what to do at this point. How do I get
it to just pause so they can go onto the next one.
 
H

Helmut Weber

Hi Debra,

for pausing a macro and allowing the user
to do something with the document,
you would need a modeless userform,
which is kind of advanced programming.

For just pausing you could use a msgbox, like:

Sub Makro2x()
Dim oFld As FormField
Dim x As Long
For Each oFld In ActiveDocument.FormFields
If oFld.Type = wdFieldFormCheckBox Then
If oFld.Result = False Then
oFld.Select
x = MsgBox("Continue?", vbOKCancel)
If x = 2 Then Exit Sub
End If
End If
Next
End Sub


--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top