If the voucher is a $$ discount off of a paid ticket, you can earn miles in all published fare classes, including Q,H,V, and W. If the voucher is for one of those post 11/9 free tickets, you shouldn't accrue mileage at all, no matter what the booking class, and that was the rule when UA gave bonus free tix as VDB compensation some years ago