View Full Version : Solved: Naming copied formfields or inserted with autotext
Hi there!
I have a problem with naming the formfields when running this code. The code works fine with formfields inserted with Forms toolbar. But with certain formfields it shows following message "This command is unavailable because the form field was not inserted with the Forms toolbar or by using the Insert Form Field dialog box." and after clicking OK "Run-time error '5149': The measurement must be between 1 pt and 1584 pt."
So, how to name the copied formfields or those inserted with autotext?
Sub NameMyForm()
For i = 1 To ActiveDocument.FormFields.Count
ActiveDocument.FormFields(i).Select
With Dialogs(wdDialogFormFieldOptions)
.Name = "MyForm" & i
.Execute
End With
Next i
End Sub
Hi there!
I found out what is the problem when I hit ALT+F9. One of the checkboxes was displayed like this: {FORMCHECKBOX}{FORMTEXT ┌}. When I deleted the second part, the code worked fine. Can somebody explain what was going on with this checkbox.
fumei
04-07-2006, 06:52 PM
It is always helpful when you fully explain what you are doing. We can not see what you are doing.
1. Why are you copying formfields? Generally speaking this is not a good idea.
2. I can run your code perfectly. It renames formfields, including ones that have been copied (and therefore have no name at all).
So....again...we can not see what you have done, so please tell us. It sounds like there may be othe rcode that are making measurement changes...or something. Hard to say, as you do not tell us.
Hi!
I found out what is the problem when I hit ALT+F9. One of the checkboxes was displayed like this: {FORMCHECKBOX}{FORMTEXT ┌}. When I deleted the second part, the code worked fine. Can somebody explain what was going on with this checkbox. As I explained earlier, the problem was caused by one of the checkboxes. This checkbox looked just fine until I hit Toggle Field Codes. Then I saw that after the checkbox in question there was additional text {FORMTEXT ┌}. I am not sure about this character "┌", but it looked similar. When I tried to debug the code stopped right there.
I solved the problem by deleting {FORMTEXT ┌}, but I am just curious what caused this? Why is it this checkbox displayed like this: {FORMCHECKBOX}{FORMTEXT ┌} instead of {FORMCHECKBOX}?
TonyJollans
04-09-2006, 11:59 PM
(chr(1)) is a placeholder for a graphic. It should not be inside a FormField. There must be something wrong with your autotext - how did you create it?
I really do not know how did I managed to create this formfield. :dunno
</IMG>
fumei
04-10-2006, 07:04 AM
Uh, you don't know how you made the formfield? How is that possible?
Did you make it by code? Is this one you copied? Did you ever have anything IN the formfield?
TonyJollans
04-10-2006, 07:14 AM
I really do not know how did I managed to create this formfield. :dunnoI guess you put this one down to experience then because no-one here can help you much more if that's the case.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.