In that case, you can use a series of tests, coded like:
Code:
{QUOTE "{MERGEFIELD Part_One}{IF{MERGEFIELD Part_One} = "???????" " "}{IF{MERGEFIELD Part_One} = "????????" " "}{IF{MERGEFIELD Part_One} = "?????????" " "}{MERGEFIELD Part_Two}" \* CHARFORMAT}
where Part_One is the name of your variable-length mergefield and Part_Two is the name of your fixed-length mergefield. Basically, the IF tests (the parts coded like {IF{MERGEFIELD Part_One} = "?" " "}) evaluate the length of the Part_One field and, according to that length, pad it out to 10 characters. The above coding representations cover from 7 to 9 characters in the Part_One data.
Note that the field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.
Strictly speaking, the QUOTE field isn't necessary but, when used with the CHARFORMAT, means you need only apply your barcode font to the 'Q' in 'QUOTE' for the whole field to be barcoded. That'll make it easier to maintain later on.