Execution Errors with Excel worker trying to use macros

Hey!

I’m trying to use the Excel worker to run macros for the first time, and I am hitting ExcecutionErrors. It only tells me that something went during in the execution of the Excel, but I am unsure where to look. The connexion to the worker seems fine (the worker starts up), we have triple checked the marco names as well as the sheet name.

This is the code we use based on the example in the docs here.

    def download_macro(self,params,**kwargs):
        filepath = Path(__file__).parent / 'Reinforcement_piles_vic_test.xlsm'

        with open(filepath, 'rb') as f:
            template=BytesIO(f.read())

        named_input_cells=[
            DirectInputCell('ELU','F', 6, 70),
            DirectInputCell('ELU','F', 7, 7),
            DirectInputCell('ELU','F', 10, 22),
            DirectInputCell('ELU','F', 11, 14.7),
            ...
        ]

        macros = [Macro('calcul_ELU'), Macro('calcul_ELS')]

        area_cell = DirectOutputCell('ELU', 'BC', 3)
        direct_output_cells = [area_cell ]        

        excel = Excel(template=template, named_input_cells=named_input_cells,
                  macros=macros, direct_output_cells=direct_output_cells)

        excel.execute(timeout=120)
 
        return DownloadResult(excel.filled_template,'output_macro.xlsx')

Try starting the worker ‘as Administrator’. That solved (some of) the problems I had using the Excel worker.

1 Like

Thanks Enrique!

To elaborate a bit more in case someone else hits the same problems. The problem did not come from the code itself, but from rights/permissions releated to excel on the machine. We were able to remove the problem with the following steps (I am not sure which subset was the actual problem):

We can now download the excel sheet filled in and it looks like the macro was executed properly. Unfortunately, when trying to read out the direct output cells there still seems to be a problem (the values that we read out look like the macro was not executed yet).