On Sun, 25 Jun 2006 09:38:56 -0700, LurfysMa <(E-Mail Removed)>
wrote:
>On Sun, 25 Jun 2006 17:27:55 +0200, "Doug Robbins - Word MVP"
><(E-Mail Removed)> wrote:
>
>>Not with a variable pitch font.
>
>I infer that you are talking about a macro that could count the
>characters in the 3 fields and then divide the remaining soace
>equally, right?
>
>Not that I'm going to do this, but isn't there some VBA command that
>willr eturn the width of a text string in a given font and size?
For the record, no, VBA doesn't have any "how wide is this string"
function that doesn't require inserting the string first. Its big
brother VB does, as do the heavy-duty languages like C++ and C#, but
VBA has always been without it. Where it is available, it's a fairly
complicated procedure -- you have to get a graphic context (a memory
area loaded with the properties of the current printer), create a font
object, pass the string and the font object to the function and get
back a width in pixels, convert that to the rendering width on the
page, and finally release the font and context objects.
The closest you can get in VBA is to insert the string in the document
and then call
Selection.Information(wdHorizontalPositionRelativeToTextBoundary),
which returns the position of the cursor in points from the left
margin.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.