Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2018, 06:40 AM
HeiFa HeiFa is offline Change font-size automatically in addressfield for only the line for name Windows 10 Change font-size automatically in addressfield for only the line for name Office 2016
Novice
Change font-size automatically in addressfield for only the line for name
 
Join Date: Mar 2018
Posts: 1
HeiFa is on a distinguished road
Default Change font-size automatically in addressfield for only the line for name

Hello everyone.

I want to update a template, where i have an addressfield.

Into this addressfield a name is inserted on the name line. It's the first line on the field.

If this name is to long, i want the font-size to adjust just so much, that the name fits one line.

This needs to fit the normal letter window envelopes, so not much space to use a to small / big font or many line breaks.

Names may vary in length alot, so if the name is too small, i'd like to avoid stretching the words over one line or having them to big all of a sudden.

I know, i can do some stuff with VBA macros, but if possible, it should be doable without them.

I found something on the net, explaining that tablecells could have this kind of behaviour, but not sure if it is applicable.


My question now is:

Can i do something like this without macros in Word 2016?



If not, how could i find a solution or explanation for what i'm looking for?
If possible, i'd like to understand what i'm supposed to to, but i have no knowledge of VBA and this stuff whatsoever.

I'd gladly take any hint, suggestion and help, you could offer me.

Please ask, if i did not explain anything necessary or when i was unclear about something.

Thank you in advance.
Reply With Quote
  #2  
Old 03-14-2018, 03:55 PM
macropod's Avatar
macropod macropod is offline Change font-size automatically in addressfield for only the line for name Windows 7 64bit Change font-size automatically in addressfield for only the line for name Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi Heifa,

What you're asking isn't possible without a macro, but a macro-driven solution can be seamless. If you add the following macro to your mailmerge main document (which you'll need to save in the docm format), and use a single-cell table to contain the address details, clicking on the 'Edit Individual Documents' button will intercept the merge, finishing it and producing an output document with any long lines compressed to fit the space available. With a few minor modifications, the macro could be made to send the output to the printer instead of leaving you with a new document.
Code:
Sub MailMergeToDoc()
Application.ScreenUpdating = False
Dim Tbl As Table, Cll As Cell, Par As Paragraph, sCllWdth As Single, sParWdth As Single
With ActiveDocument
  With .Tables(1)
    For Each Cll In .Range.Cells
      Cll.WordWrap = False
    Next
    With .Cell(1, 1)
      sCllWdth = .Width - .LeftPadding - .RightPadding
    End With
  End With
  .MailMerge.Execute
End With
With ActiveDocument
  For Each Tbl In .Tables
    For Each Cll In Tbl.Range.Cells
      If Len(Cll.Range) > 2 Then
        For Each Par In Cll.Range.Paragraphs
          With Par.Range
            sParWdth = .Characters.Last.Previous.Information(wdHorizontalPositionRelativeToPage)
            sParWdth = sParWdth - .Characters.First.Information(wdHorizontalPositionRelativeToPage)
            If sParWdth + Par.LeftIndent > sCllWdth Then .FitTextWidth = sCllWdth - Par.LeftIndent
            If .Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) <> _
              .Characters.First.Information(wdVerticalPositionRelativeToPage) Then
              .FitTextWidth = sCllWdth - Par.LeftIndent
            End If
          End With
        Next
      End If
    Next
  Next
End With
Application.ScreenUpdating = True
End Sub
Note 1: The code assumes the table used to hold the addressing is the only table in the document; changes might be needed if there are other tables.

Note 2: You shouldn't use the mailerge 'addressblock' field for this - insert the individual mergefields instead, with paragraph breaks separating the various address lines.

For the single-cell table, to set the fixed:
• row height, use Table Tools>Layout>Properties>Row>Specify Height>Exactly.
• column width, first uncheck the 'automatically resize to fit contents' option under Table Tools>Layout>Properties>Table>Options. Then set the preferred column width under Table Tools>Layout>Properties>Columns.
You might also want to set the cell margins to 0 all round and format the cell paragraphs with 0 before/after spacing.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change font-size automatically in addressfield for only the line for name Looping Macro to Change Font, Font Size, and Give Heading 1 WH7262 Word VBA 1 08-26-2014 03:46 PM
Unable to change font size Andoheb Outlook 1 11-23-2012 07:24 PM
Change font-size automatically in addressfield for only the line for name how change size font to inches size kkepo Word 4 08-28-2012 08:53 PM
Change font-size automatically in addressfield for only the line for name Change font & point size? markg2 Outlook 2 06-09-2010 03:23 PM
Can't change font type or size sideways Word 2 11-01-2009 09:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:41 PM.


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