Finding the length of proportional text strings
Unless I am mistaken your answer only works for fixed length fonts. The
problem is I am using proportional fonts where the length of the string is
character dependent.
--
russ
"Keith74" wrote:
On 12 Feb, 14:19, Russ wrote:
I need to combine two text cells in Excel into one character string with
filler dot characters in the middle to produce a character string of a fixed
length in inches that will end up in a Microsoft Word table. The fonts are
proportional and the same in both Excel and the Word table. For example
Left string - "AAAAAA"
Right string - "BBBBB"
Concatenated string with filler dots - "AAAAAA......BBBBB"
The only way I have found so far is to build the string putting one dot at
time in the middle until the string wraps in a cell who's width is set equal
to the Word table cell width. By testing the height of the cell I can tell
when the cell wraps and the length has been exceeded. Is there a better way
to accomplish this?
--
russ
Public Sub CreateString()
Dim strString1 As String
Dim strString2 As String
Dim intRequiredLength As Integer
Dim strFinalString As String
strString1 = "AAAAAA"
strString2 = "BBBBBB"
intRequiredLength = 15
Do Until Len(strString1) + Len(strString2) = intRequiredLength
strString1 = strString1 & "."
Loop
strFinalString = strString1 + strString2
End Sub
hth
|