I have a word table that has a cell containing a numerical value... I want
to add leading zeros to this value via a formula...

I am new to Word VBA, but I know that this can be done using Access VBA.
Apparently Word VBA <> Access VBA correct ?

Otherwise this should work....

Format$(Fieldname, "000000")

or

Right$("000000" & Trim$(Fieldname), 6)

Any Word Equivalents for these ?

Re: How to format values in a table ? by macropod

macropod
Wed Jul 23 14:24:08 PDT 2008

Hi Rob,

How is the value getting into the cell (eg formfield, formula field, vba, typing)?

--
Cheers
macropod
[MVP - Microsoft Word]


"Rob" <robc1@yahoo.com> wrote in message news:9cqdnUATQuPVBRrVnZ2dnUVZ_oninZ2d@comcast.com...
>I have a word table that has a cell containing a numerical value... I want
> to add leading zeros to this value via a formula...
>
> I am new to Word VBA, but I know that this can be done using Access VBA.
> Apparently Word VBA <> Access VBA correct ?
>
> Otherwise this should work....
>
> Format$(Fieldname, "000000")
>
> or
>
> Right$("000000" & Trim$(Fieldname), 6)
>
> Any Word Equivalents for these ?
>
>

Re: How to format values in a table ? by Rob

Rob
Wed Jul 23 15:22:26 PDT 2008

Thanks for responding...

It is actually coming from a 3rd party erp system... but my guess would be
"formfield" as you map them from the erp system into a table in the word doc
template.


"macropod" <macropod@invalid.invalid> wrote in message
news:eleQypQ7IHA.1200@TK2MSFTNGP04.phx.gbl...
> Hi Rob,
>
> How is the value getting into the cell (eg formfield, formula field, vba,
> typing)?
>
> --
> Cheers
> macropod
> [MVP - Microsoft Word]
>
>
> "Rob" <robc1@yahoo.com> wrote in message
> news:9cqdnUATQuPVBRrVnZ2dnUVZ_oninZ2d@comcast.com...
>>I have a word table that has a cell containing a numerical value... I want
>>to add leading zeros to this value via a formula...
>>
>> I am new to Word VBA, but I know that this can be done using Access VBA.
>> Apparently Word VBA <> Access VBA correct ?
>>
>> Otherwise this should work....
>>
>> Format$(Fieldname, "000000")
>>
>> or
>>
>> Right$("000000" & Trim$(Fieldname), 6)
>>
>> Any Word Equivalents for these ?
>>


Re: How to format values in a table ? by macropod

macropod
Wed Jul 23 17:01:34 PDT 2008

Hi Rob,

OK, to test whether the value is in a formfield, press Alt-F9. If the value is in any sort of field, the cell's contents will change
to something bound by a pair of field braces (ie '{}'). If it's a formfield you should see something like '{ FORMTEXT }' or '{
FORMTEXT { =12345 }}'. If that's what you see, right-click on the field and choose 'properties', then make sure the 'type' is set to
'number' and insert as many 0s as you need in the 'number format' box. If you make these changes to the template the document is
based on, any new documents will automatically get the required number of leading 0s.

No vba required.

Press Alt-F9 again to toggle the field code display off.


--
Cheers
macropod
[MVP - Microsoft Word]


"Rob" <robc1@yahoo.com> wrote in message news:keSdnetCxPG_MhrVnZ2dnUVZ_rTinZ2d@comcast.com...
> Thanks for responding...
>
> It is actually coming from a 3rd party erp system... but my guess would be "formfield" as you map them from the erp system into a
> table in the word doc template.
>
>
> "macropod" <macropod@invalid.invalid> wrote in message news:eleQypQ7IHA.1200@TK2MSFTNGP04.phx.gbl...
>> Hi Rob,
>>
>> How is the value getting into the cell (eg formfield, formula field, vba, typing)?
>>
>> --
>> Cheers
>> macropod
>> [MVP - Microsoft Word]
>>
>>
>> "Rob" <robc1@yahoo.com> wrote in message news:9cqdnUATQuPVBRrVnZ2dnUVZ_oninZ2d@comcast.com...
>>>I have a word table that has a cell containing a numerical value... I want to add leading zeros to this value via a formula...
>>>
>>> I am new to Word VBA, but I know that this can be done using Access VBA. Apparently Word VBA <> Access VBA correct ?
>>>
>>> Otherwise this should work....
>>>
>>> Format$(Fieldname, "000000")
>>>
>>> or
>>>
>>> Right$("000000" & Trim$(Fieldname), 6)
>>>
>>> Any Word Equivalents for these ?
>>>
>


Re: How to format values in a table ? by Rob

Rob
Thu Jul 24 03:02:23 PDT 2008

Thanks again for your time...

But I guess it is not a formfield after all... I pressed Alt-F9 and all that
was present was an empty table. I assume the erp is populating it
dynamically and thus there is no way to intervene with a formatting
override.

rob


"macropod" <macropod@invalid.invalid> wrote in message
news:OxG2wBS7IHA.4532@TK2MSFTNGP05.phx.gbl...
> Hi Rob,
>
> OK, to test whether the value is in a formfield, press Alt-F9. If the
> value is in any sort of field, the cell's contents will change to
> something bound by a pair of field braces (ie '{}'). If it's a formfield
> you should see something like '{ FORMTEXT }' or '{ FORMTEXT { =12345 }}'.
> If that's what you see, right-click on the field and choose 'properties',
> then make sure the 'type' is set to 'number' and insert as many 0s as you
> need in the 'number format' box. If you make these changes to the template
> the document is based on, any new documents will automatically get the
> required number of leading 0s.
>
> No vba required.
>
> Press Alt-F9 again to toggle the field code display off.
>
>
> --
> Cheers
> macropod
> [MVP - Microsoft Word]
>
>
> "Rob" <robc1@yahoo.com> wrote in message
> news:keSdnetCxPG_MhrVnZ2dnUVZ_rTinZ2d@comcast.com...
>> Thanks for responding...
>>
>> It is actually coming from a 3rd party erp system... but my guess would
>> be "formfield" as you map them from the erp system into a table in the
>> word doc template.
>>
>>
>> "macropod" <macropod@invalid.invalid> wrote in message
>> news:eleQypQ7IHA.1200@TK2MSFTNGP04.phx.gbl...
>>> Hi Rob,
>>>
>>> How is the value getting into the cell (eg formfield, formula field,
>>> vba, typing)?
>>>
>>> --
>>> Cheers
>>> macropod
>>> [MVP - Microsoft Word]
>>>
>>>
>>> "Rob" <robc1@yahoo.com> wrote in message
>>> news:9cqdnUATQuPVBRrVnZ2dnUVZ_oninZ2d@comcast.com...
>>>>I have a word table that has a cell containing a numerical value... I
>>>>want to add leading zeros to this value via a formula...
>>>>
>>>> I am new to Word VBA, but I know that this can be done using Access
>>>> VBA. Apparently Word VBA <> Access VBA correct ?
>>>>
>>>> Otherwise this should work....
>>>>
>>>> Format$(Fieldname, "000000")
>>>>
>>>> or
>>>>
>>>> Right$("000000" & Trim$(Fieldname), 6)
>>>>
>>>> Any Word Equivalents for these ?
>>>>
>>
>



Re: How to format values in a table ? by Graham

Graham
Thu Jul 24 04:56:07 PDT 2008

Given that the content appears to be text, the following macro will format a
chosen column in the format "00000"

Sub FormatColumn()
Dim cTable As Table
Dim rName As Range
Dim sCell As String
Dim rText As Range
Dim i As Long
Dim v As Long

v = InputBox("Format which column", , 3)
'v = 3
Set cTable = ActiveDocument.Tables(1)

On Error Resume Next
For i = 1 To cTable.Rows.Count
Set rName = cTable.Cell(i, v).Range
sCell = Left(rName, Len(rName) - 1)
rName = Replace(rName, sCell, Format(sCell, "00000"))
Next i
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Rob wrote:
> Thanks again for your time...
>
> But I guess it is not a formfield after all... I pressed Alt-F9 and
> all that was present was an empty table. I assume the erp is
> populating it dynamically and thus there is no way to intervene with
> a formatting override.
>
> rob
>
>
> "macropod" <macropod@invalid.invalid> wrote in message
> news:OxG2wBS7IHA.4532@TK2MSFTNGP05.phx.gbl...
>> Hi Rob,
>>
>> OK, to test whether the value is in a formfield, press Alt-F9. If the
>> value is in any sort of field, the cell's contents will change to
>> something bound by a pair of field braces (ie '{}'). If it's a
>> formfield you should see something like '{ FORMTEXT }' or '{
>> FORMTEXT { =12345 }}'. If that's what you see, right-click on the
>> field and choose 'properties', then make sure the 'type' is set to
>> 'number' and insert as many 0s as you need in the 'number format'
>> box. If you make these changes to the template the document is based
>> on, any new documents will automatically get the required number of
>> leading 0s. No vba required.
>>
>> Press Alt-F9 again to toggle the field code display off.
>>
>>
>> --
>> Cheers
>> macropod
>> [MVP - Microsoft Word]
>>
>>
>> "Rob" <robc1@yahoo.com> wrote in message
>> news:keSdnetCxPG_MhrVnZ2dnUVZ_rTinZ2d@comcast.com...
>>> Thanks for responding...
>>>
>>> It is actually coming from a 3rd party erp system... but my guess
>>> would be "formfield" as you map them from the erp system into a
>>> table in the word doc template.
>>>
>>>
>>> "macropod" <macropod@invalid.invalid> wrote in message
>>> news:eleQypQ7IHA.1200@TK2MSFTNGP04.phx.gbl...
>>>> Hi Rob,
>>>>
>>>> How is the value getting into the cell (eg formfield, formula
>>>> field, vba, typing)?
>>>>
>>>> --
>>>> Cheers
>>>> macropod
>>>> [MVP - Microsoft Word]
>>>>
>>>>
>>>> "Rob" <robc1@yahoo.com> wrote in message
>>>> news:9cqdnUATQuPVBRrVnZ2dnUVZ_oninZ2d@comcast.com...
>>>>> I have a word table that has a cell containing a numerical
>>>>> value... I want to add leading zeros to this value via a
>>>>> formula... I am new to Word VBA, but I know that this can be done
>>>>> using
>>>>> Access VBA. Apparently Word VBA <> Access VBA correct ?
>>>>>
>>>>> Otherwise this should work....
>>>>>
>>>>> Format$(Fieldname, "000000")
>>>>>
>>>>> or
>>>>>
>>>>> Right$("000000" & Trim$(Fieldname), 6)
>>>>>
>>>>> Any Word Equivalents for these ?