GAMS run sequence

Top  Previous  Next

Further down in trancode is the section that runs GAMS.  It consists of the lines below and is not likely to need to be changed by the user

 

    'save the file

        ActiveWorkbook.Save

ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\excelincharge.XLS", FileFormat:= _

xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _

           , CreateBackup:=False

        savename = ActiveWorkbook.Name

     'run the GAMS job

       'define additional parameters to attach to GAMS Call

       params = ""

       'now run gams

       lGAMSRet = GAMSrun(params, sGAMSFile)

     'reload the file with the data passed from GAMS

      ActiveWorkbook.Save

     

This progresses through several steps

The workbook is saved and remaned  so that when GAMS runs it can read the latest input data from the inputs sheet (note Gdxxrw can read from an open workbook but addresses the data in the saved fiole on disk.  Also Gdxxrw cannot write to an open workbook that is not shared but does so slowly.  Thus temporarily rename the worksheet so the source worksheet can be written to.).
GAMS is run using the GAMS solution Macro procedure gamsrun that is in the Visual Basic module also in the spreadsheet called rungams.
The spreadsheet which now contains the data placed by GAMS into the worksheet is reloaded by executing a save command.