Own Vat code

M

mrodwell

I am using the below code in a Add button on a userform.

'Vat box'
If chkVAT = True Then
Selection.GoTo what:=wdGoToBookmark, Name:="vat"
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"=c6 * 17.5% \#""#,##0.0""", PreserveFormatting:=False
End If

This works a treat and when the tick is in the box The VAT is worked
out correctly...BUT when there is no tick it still adds the VAT on i
have tried to add a If chkVAT = false then style command but it still
adds on the VAT...have you any ideas where i have gone wrong.

Matthew.
thanks in advance
 
P

Peter Jamieson

You are adding a field if chkVAT is True. But are you removing it when
chkVAT is False?
 
M

mrodwell

At the moment in time no...because i wasn't sure what to put. I just
want it to be '0'...help.please
 
D

Doug Robbins - Word MVP

Hi Mathew,

In your userform code, use

If chkVAT = True then
ActiveDocument.Variables("VAT").Value = .175
Else
ActiveDocument.Variables("VAT").Value = 0
End if
ActiveDocument.Fields.Update

then in the template, in the cell in which you want the VAT to appear,
insert the following field construction:

{ = c6 * { DOCVARIABLE "VAT" } \# ",0.0;;" }

Then that cell will display 17.5% of the value in c6 if VAT is applicable
and nothing if it is not. If you want 0.0 to appear if VAT is not
applicable, omit the two semi colons.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top