Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to update ToC in a form - I'm stuck! | Microsoft Word Help | |||
Adding Autotext in a Macro User Form field | Microsoft Word Help | |||
Add a new page in a form by using a macro??? | Microsoft Word Help | |||
Text Form Field Ref in Footer Won't Update on Screen | Microsoft Word Help | |||
Form Field Automation | Microsoft Word Help |