I am trying to run a couple of instances of gams in a sequential manner.
I use excel to change parameters and other input data and I execute gams from a VBA macro which executes Gams through acommand shell.

I have tried some approaches to wait for the GAMS code to finish running to change the parameters and execute the gams code automatically, but so far none has worked.

Approaches I have tried :
In VBA run a wait code so the VBA code waits around 1 minute (while my GAMS code runs in around 45sec).
In VBA run a code so it checks for a results file that GAMS creates to appear and then continue with code.
In vba check if the gams.exe process is running and as soon as it stops running (+5sec) continue with the code.

All these approaches make GAMS stop before running the model. The only approach that seems to be working is to set a msgbox and when gams stops running I manually click on the message box button to continue with the VBA code.

The cmd stops at this point, where it normally continues running creating all the results files.

The difference is that my model is already written in a .gms file and the model itself creates all the necessary gdx files.

So when I try to adapt this code to run my model (deleting exportgdxfile,writegamsmodel and importgdxfile) and change the directories to the correct ones for my model it doesn't run. It just briefly shows the command window for 1 millisecond. This is my VBA cose to call GAMS :