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 / June 2007

Tip: Looking for answers? Try searching our database.

A macro to replace check boxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Josh - 26 Jun 2007 19:47 GMT
Does anyone have a macro that will replace every formfield check box
that is true with the capital letter "X"?  I want the user to click a
commend button on the form and the macro will replace all the check
boxes that are true with a "x" and just delete the check boxes that
are false.  I can probably do it myself if I use bookmarks and write
logic for each checkbox but i have over 300 on the word document!  Any
help would be excellent, thank you!
Bear - 26 Jun 2007 20:32 GMT
Josh:

This should work. I'm not using the formfields collection because I'm
deleting the fields as I go. I start by unprotecting the document and end by
reprotecting it. Whether or not you reprotect is up to your application. --
Bear

Sub x()

Dim I As Integer

ActiveDocument.Unprotect

For I = ActiveDocument.FormFields.Count To 1 Step -1
   With ActiveDocument.FormFields(I)
   If .Type = wdFieldFormCheckBox Then
       If .CheckBox.Value = True Then
           .Range = "X"
       Else
           .Delete
       End If
   End If
   End With
Next I

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

End Sub

Signature

Windows XP, Word 2000

Josh - 27 Jun 2007 18:58 GMT
This works great!  Thank you so much, Bear!

-Josh
Bear - 27 Jun 2007 19:36 GMT
Josh:

Glad I could help out. Thanks for rating the post!

Bear

Signature

Windows XP, Word 2000

> This works great!  Thank you so much, Bear!
>
> -Josh
 
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.