@piggychops – I'm not exactly sure, but by that code you only cycle through the states of the MSOs.
You never change its visible appearance on the page, because the active state of the MSO is always the same state.
So you'll end up with always the same contents that is exported to PNG (do you get that result?).
To get all states active, set the states in the loop (one after another) to the active one and then export to PNG.
MSO.states[i].active = true;
But before, store the current active state, so that you can return to the original appearance…
Something slightly different, but the code may help you (all comments are in German, but that should be no problem):
Multistateobject exportFile Problem
These links are useful. But in that link it is exporting whole page as mso jpg image. I want those portion only where my mso exist. Means i dont want any blank space in my mso image. For that what i have to do. Please let me know.
@piggychops – you could adapt one of the scripts that are posted at one of the links regarding the "state.active" thing.
What you then need is access to the objects in the particular active state.
You could duplicate all pageItems of that state, group the duplicate, if there is more than one pageItem, export the group, finally remove the group and go on to the next state.