Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Search for an Unchecked Checkbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debra Ann - 11 Mar 2008 14:26 GMT
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,

Signature

Debra Ann

Helmut Weber - 11 Mar 2008 15:35 GMT
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

Signature

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Word 2002, Windows 2000 (german versions)

Debra Ann - 11 Mar 2008 15:50 GMT
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.
Signature

Debra Ann

> Hi Debra,
>
[quoted text clipped - 9 lines]
> Next
> End Sub
Helmut Weber - 11 Mar 2008 16:48 GMT
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
Debra Ann - 11 Mar 2008 17:41 GMT
That worked perfectly.  Thanks so much.
Signature

Debra Ann

> Hi Debra,
>
[quoted text clipped - 26 lines]
>
> Vista Small Business, Office XP
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.