Magnetic fields in barred galaxies - IV. NGC 1097 and NGC 1365