You need to change the way yoyur menu is implemented,
You should use
create [a] [new] gui [[with id] %-string%] with %inventory% [and shape %-strings%]
inventory type is in your case: virtual chest
put a : after that and add 1 indent to all format code with format (below)
to open the menu, use
last[ly] [created] gui
open last gui to player
but I recommend giving a gui a id.You can: edit it before opening to the player, register the GUI in a on load event and call the menu from different events.
open gui %string% to player