In summary, to automatically replace a part in a SolidWorks assembly, you can use the "Replace Components" feature by right-clicking on the part in the assembly tree and selecting "Replace Components". You can also replace multiple parts at once by selecting them in the assembly tree and using the same feature. There is also a "Smart Components" feature that allows for automatic replacement of similar parts. If you need to undo a part replacement, you can use the "Undo" command or Ctrl+Z. When replacing a part, the mates and relationships will automatically be applied to the new part to maintain the assembly's integrity.
Your specification is rather terse -- my immediate conjecture is no -- perhaps if you provide more information you might get a more informed answer -- I don't know SolidWorks, but I know well what machines can and cannot do.