in 2010 and later this code also works, and it checks to see if the button to minimize the ribbon is already pressed first so it doesn't maximize the ribbon if it is already minimized:
If Not CommandBars.GetPressedMso("MinimizeRibbon") Then
CommandBars.ExecuteMso "MinimizeRibbon"
End If