I recorded this macro to automatically insert a formula into a custom field, but this error always appears. Can someone help me?

Insert a formula into a custom field via VBA. Displaying error message.
this is the code I'm using:
CustomFieldSetFormula FieldID:=pjCustomTaskText1, Formula:="format(IIf([Custo]=0;[% trabalho concluído];[COTA]/[Custo]*100);#0.0) & %"
CustomFieldPropertiesEx FieldID:=pjCustomTaskText1, Attribute:=pjFieldAttributeFormula, SummaryCalc:=pjCalcFormula, GraphicalIndicators:=False, AutomaticallyRolldownToAssn:=False
There are a few different things wrong with the code.
Try this construct, it works for me: CustomFieldSetFormula FieldID:=pjCustomTaskText2, Formula:="IIf([Custo]=0,[% trabalho concluido],format([COTA]/[Custo]*100,""#0.0"") & ""%"")" CustomFieldPropertiesEx FieldID:=pjCustomTaskText2, Attribute:=pjFieldAttributeFormula, SummaryCalc:=pjCalcNone, GraphicalIndicators:=False, AutomaticallyRolldownToAssn:=False