It is true that
formfield checkboxes do not have text with them. However, ActiveX checkboxes DO.
Since users want to change the text of each checkbox based on the date they entered
I am not getting this. A checkbox is used to check things. It is either checked, or not checked. The result, the consequences, of a check (or not check) may be all sorts of things. But are you really changing the text of the checkbox? No, you may be changing the text of a textbox - or something else.
OK, if you have the complication of the formfields being in tables, AND the users can delete the tables...then yeah....that would be complex to set up.
However, it certainly could be done. After all, the whole issue is still one of logic. It is just a bunch of logic statements really.
IF the user has set it with THIS condition THEN
the document looks like this
ELSE (the user has NOT set it as THIS condition)
the document looks like this different way
END IF
Or, if it gets very complex, you could change it to Select Case type logic.
Select Case
whatever it is you are basing things on
Case
if it is this way
make the document like this
Case
if it is this other way
make the document like this
Case
if it is this even MORE different way
make the document like this
Case Else
give a message to user..."Huh?"
End Select
All that is nice to say of course...but, as you have inherited the document, I realize that you may not have design control over it.
is i use the add method, i need to give a start and end range.
Not quite accurate, as you do not need to specify the explicit Start and End Range integers. You can use Selection.Range.
So go to where you want to add the formfield (make sure you add the proper spaces if required) and do something like:
Code:
Sub AddFF()
ActiveDocument.FormFields.Add Range:=Selection.Range, _
Type:=wdFieldFormCheckBox
Selection.MoveLeft unit:=wdCharacter, Count:=1
With Selection.FormFields(1)
.Name = "Bob"
.ExitMacro = "TestMe"
End With
End Sub
I put the other stuff in to demonstrate that you can:
1. add the formfield at the selection point
2. back up the selection
3. set the attributes/properties of the new formfield
In this case I explicitly named the checkbox formfield "Bob", and made it fire the procedure "TestMe" when it is exited.
It seems that you are using some OnExit macros, so it may be important to be able to put those macros on a newly created formfield.
I strongly suggest that you always explicitly name your formfields (or ANY other control for that matter).
Also, it may be important (just in case) to .Collapse the Selection before you use it to make a formfield.
All in all though, my instincts tell me that this thing could probably be designed a bit better. Again, though, it it was handed to you, that may not be an option.
Gerry
My paintings and sculpture