Decided to look at your code. Was this something that you generated? Basically, it doesn't do anything. First, it selects everything on 1st page. Next, it creates a group for everything selected, and then, ungroups it. Never gets to next page.
The issues with this code
>> the selectall will never accomplish what you want it to. It will not select any child shapes; kjust top level single shapes and group parent shapes.
>> the group line should be deleted
>> the ungroup could be changed to vsSelection.ungroup. That does work. But if there are additional groups, it needs to iterate again...and again until all groups are dissolved. The For ... Next loop doesn't accommodate this. It needs to be recursive.