Yes. Most of the time women don't know exactly which hpv type they are infected with. In addition, women often clear hpv infection all by themselves! for these reasons, you should be vaccinated regardless of hpv status since you still may derive some benefit from the vaccine.
Define "have" HPV is a family of viruses. Most adults will eventually be exposed to several strains. The present (2017) Gardasil 9 has material in it to help protect against 7 strains associated with genital cancer and 2 associated with genital warts. It could help anyone not carrying the risky strains. At a listed age of 40 you would beyond the target age where insurers might pay for the vaccines series.