Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2016, 06:55 AM
lovetowaltz lovetowaltz is offline Windows 10 Office 2007
Novice
format form fields
 
Join Date: Dec 2016
Posts: 1
lovetowaltz is on a distinguished road
Default format form fields

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,
Reply With Quote
  #2  
Old 12-08-2016, 02:49 PM
macropod's Avatar
macropod macropod is offline format form fields Windows 7 64bit format form fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
format form fields 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
format form fields Unable to format fields pro3carp3 Word 1 03-04-2014 02:49 PM
format form fields 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft