Solved

MS Word - Autosize Font in Text Boxes

Posted on 2013-10-22
8
1,595 Views
Last Modified: 2013-10-28
Hello, MS Word experts. Let's say I create a text box that is defined with a specific textbox size (say 2" x 1") and a specific font size (say 12pt).

Is there a way to make that text box's font automatically decrease to fit the 2"x1" so the text, if it's longer than 2", is fully seen in the box? I, basically, don't want to have to make the box bigger if there is text in it that doesn't fit the initial sizes.

I'm asking because I want to send text to a text box from a .NET program and the text that gets sent may be longer than the specified dimensions of the textbox.

Thanks!
0
Comment
Question by:infotechelg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 36

Expert Comment

by:Kimputer
ID: 39592861
Probably something along the line of:
Private Sub TextBox1_Change()
If Len(TextBox1.Text) > 10 Then
    TextBox1.Font.Size = 5
Else
    TextBox1.Font.Size = 20
End If
End Sub

Open in new window

You need to do the tweaking, as in, decide lenght of text, and fontsize. Maybe add more case or ifs.
0
 

Author Comment

by:infotechelg
ID: 39594086
This is a macro, then, in Word?
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 39594180
Officially, it's not a macro perse, as those are things you run manually. This one is more Event driven (it changes while you type in the textbox), but you have to put it in the same spot (ALT+F11 to open VBA editor)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:infotechelg
ID: 39594215
But I will not be typing in the textbox. .NET is going to populate a text box with text. Will it still work?
0
 

Author Comment

by:infotechelg
ID: 39594237
I don't think this is going to work for me. I find it hard to believe there's no option in Word for text to fit into the confined space of a textbox. It seems like something that would be a common request.
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 39594295
This code works as long as there are changes made to the textbox. That could be typing, but automated population should also work.
The properties for a textbox are all layed out before you. There are no secret properties that allow you to automatically adjust the font, not even in the Visual Basic 2010 edition (more advanced than Words VBA Textbox).
0
 

Accepted Solution

by:
infotechelg earned 0 total points
ID: 39595588
I ended up handling this in the .NET code. Hopefully, MS will add this feature sometime in the future.
0
 

Author Closing Comment

by:infotechelg
ID: 39605122
Went a different route.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question