Hello, I have built this code in python - as a mere example - to open a specific Excel file using the Win32.client where I need to add a specific DSGRID code to fetch some data in Datastream with the COM addin.
# # Open an existing workbook # import win32com.client as win32 # Set-up a Connection With Excel excel = win32.gencache.EnsureDispatch('Excel.Application') # Open An Existing File wb = excel.Workbooks.Open(r'C:\Users\anilo\Downloads\add_a_workbook.xlsx') # Select A Sheet And Write In A Cell ws = wb.Worksheets("Sheet1") ws.Cells(1, 1).Value = '=@DSGRID("PCH#(S&PCOMP,1M)"," ","-2Y","","M","RowHeader=true;ColHeader=true;DispSeriesDescription=false;YearlyTSFormat=false;QuarterlyTSFormat=false","")' # Activate COM Addins excel.COMAddIns("PowerlinkCOMAddIn.COMAddIn").Connect = True # Refresh all data connections wb.RefreshAll() # Show Excel excel.Visible = True # Quit Excel excel.Application.Quit()
Unfortunately the code is not able to refresh the sheet (and thus then potentially save & close the file). Is there any possibility to refresh a DSGRID code via Python using the win32com ?