![]() |
|
#1
|
|||
|
|||
|
Hi and thank you for your help.
I am creating a form and it uses check boxes and form fields. I want to lock the form field to a specific size to accommodate only a specific number of characters, and I know how to set the properties to do this. What I want to do is if the user types more characters than allowed, have the font reduce size automatically so the user can continue typing and not affect the next form field from moving to the next line in the document. I have seen a form field that works this way and was needing this same functionality in my form. Any help you can provide is greatly appreciated. Thank you, |
|
#2
|
||||
|
||||
|
You could use a pair of on-entry and on-exit macros such as:
Code:
Sub FldExit()
Application.ScreenUpdating = False
Dim sTxtWdth As Single, sFldWdth As Single, sPrnWdth As Single
sFldWdth = InchesToPoints(2.5)
With ActiveDocument.FormFields(1).Range
With .Sections(1).PageSetup
sPrnWdth = .PageWidth - .LeftMargin - .RightMargin - .Gutter
End With
sTxtWdth = .Characters.Last.Previous.Information(wdHorizontalPositionRelativeToPage)
sTxtWdth = sTxtWdth - .Characters.First.Information(wdHorizontalPositionRelativeToPage)
Do While .Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) <> _
.Characters.First.Information(wdVerticalPositionRelativeToPage)
.Font.Scaling = sFldWdth / (sTxtWdth + sPrnWdth) * 100
Loop
If sTxtWdth > sFldWdth Then .Font.Scaling = sFldWdth / sTxtWdth * 100
End With
Application.ScreenUpdating = True
End Sub
Sub FldEntry()
ActiveDocument.FormFields(1).Range.Font.Scaling = 100
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Don't clear form fields when protecting as a form
|
BruceM | Word | 5 | 10-06-2016 08:26 AM |
| Macro to keep formatted form fields after mail merge or replace text with formatted form fields | jer85 | Word VBA | 2 | 04-05-2015 10:00 PM |
Unable to format fields
|
pro3carp3 | Word | 1 | 03-04-2014 02:49 PM |
Form Fields - Create blank form text field with if statement?
|
LAssist2011 | Word | 5 | 12-14-2011 03:02 PM |
| Form Fields | questions | Word | 0 | 04-27-2009 10:48 AM |