Viewport Macros trouble

I’m trying to set up my macro keyboard with shortcut keys to change my viewports. My aim is to have a button for each of the views, top, back, bottom, perspective etc etc so that when I press each one it switches to a single page view of that chosen view just as you would if you double clicked the view name in the top left of a viewport. Ive tried every possible macro I can think of and the best I have come up with that works but is clunky is this.

_maxviewport _setactiveviewport perspective _maxviewport _setactiveviewport perspective

for some reason you have to repeat the command otherwise it doesnt work. Ive tried other ways but they seem to change the viewport structure whenever I go back to a 4 view layout.

The other issue I have is this method only works for Persepctive, Top, Front and Right. When I try with other views such as Left, Bottom, back etc it says ‘unable to find viewport named back’

I would really appreciate any suggestions to these issues. I just need the macro that would emulate a double click on the viewport name that you find in the top left of a viewport.