Reply
 
Thread Tools Display Modes
  #1   Report Post  
coginthemachine
 
Posts: n/a
Default Search for Checkbox Form field in a macro

I am trying to create a form that allows users to checkbox a section of text
for deletion in a macro. I have created checkboxes for each section and the
users check the box if they want keep that section. I am trying to write a
macro to remove all sections of text that were unchecked after they are
finished with the document. Is there an easy way to search for a checkbox
form field, and determine if it is checked or not? If there is, I can
highlight and delete up to the next section. I am not a VB programmer.
Anyone have any creative ideas? Thanks.
  #2   Report Post  
Dian D. Chapman, MVP
 
Posts: n/a
Default

Note that you should post VBA question in one of the VBA groups in the
future.

But this code should get you started. It'll find all the checkboxes in
a doc and let you know, though a message, if they are checked and
their name. Just delete the MsgBox lines or put an apostrophe in front
of them so they will be ignored.

Sub FindCheckboxes()

Dim fld As FormField

For Each fld In ActiveDocument.FormFields
If fld.Type = wdFieldFormCheckBox Then
If fld.CheckBox.Value = True Then
'do something here to select/delete text
MsgBox "This checkbox is checked: " & fld.Name
Else
MsgBox "This checkbox is not checked: " & fld.Name
End If
End If
Next fld
End Sub

If you need help getting this code into your document, read this
TechTrax article:

Sharing Macros
http://pubs.logicalexpressions.com/P...cle.asp?ID=166

Good luck...

Dian D. Chapman, Technical Consultant
Microsoft MVP, MOS Certified
Editor/TechTrax Ezine

Free MS Tutorials: http://www.mousetrax.com/techtrax
Free Word eBook: http://www.mousetrax.com/books.html
Optimize your business docs: http://www.mousetrax.com/consulting
Learn VBA the easy way: http://www.mousetrax.com/techcourses.html


On Tue, 22 Feb 2005 14:17:02 -0800, coginthemachine
wrote:

I am trying to create a form that allows users to checkbox a section of text
for deletion in a macro. I have created checkboxes for each section and the
users check the box if they want keep that section. I am trying to write a
macro to remove all sections of text that were unchecked after they are
finished with the document. Is there an easy way to search for a checkbox
form field, and determine if it is checked or not? If there is, I can
highlight and delete up to the next section. I am not a VB programmer.
Anyone have any creative ideas? Thanks.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to update ToC in a form - I'm stuck! La La Lara Microsoft Word Help 7 February 24th 05 10:27 PM
Adding Autotext in a Macro User Form field Onka Microsoft Word Help 1 February 10th 05 05:39 AM
Add a new page in a form by using a macro??? La La Lara Microsoft Word Help 1 January 19th 05 05:41 PM
Text Form Field Ref in Footer Won't Update on Screen StarWine Microsoft Word Help 3 December 6th 04 06:17 PM
Form Field Automation Mitch Microsoft Word Help 2 November 29th 04 07:29 PM


All times are GMT +1. The time now is 08:34 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"