Films of polymethyl methacrylate and methyl methacrylate copolymers with ethylhexyl acrylate doped with HAuCl4 were subjected to UV irradiation followed by thermal treatment at various temperatures. The films were studied by absorption spectroscopy and small-angle X-ray scattering. The photolysis of HAuCl4 was found to result in the formation of gold nanoparticles, whose size depended on the structure of the polymeric matrix. An increase in the free volume of polymers caused the formation of larger particles.