Why you want to use macro when you can do that manually with simple steps.
- Click in graphics area and press Ctrl + A
- Right click anywhere and select and make virtual.
- Select the option "Make Sub assembly and all child components virtual" on the prompt window
- And save as needed.
I'm on SW2015. When i select make virtual after selecting all components I do not get any prompt window. This feature is appears in 2016++ . That's why i am attempting to write a macro for this.