# IronPython imports to enable Excel interop import clr clr.AddReference("Microsoft.Office.Interop.Excel") import Microsoft.Office.Interop.Excel as Excel workingDir = AbsUserPathName("C:\Users\shreepal\Downloads\Compressed/") def updateHandler(): # Define key ranges in the Workbook lenCell = worksheet.Range["B6"] ldCell = worksheet.Range["B7"] dfCell = worksheet.Range["B8"] # Get the Workbench Parameters lenParam = Parameters.GetParameter(Name="P1") ldParam = Parameters.GetParameter(Name="P2") dfParam = Parameters.GetParameter(Name="P3") # Assign values to the input parameters lenParam.Expression = lenCell.Value2.ToString() ldParam.Expression = ldCell.Value2.ToString() # Mark the deformation parameter as updating in the workbook dfCell.Value2="Updating..." # Run the project update Update() # Update the workbook value from the WB parameter dfCell.Value2 = dfParam.Value.Value # Open the Workbench Project Open(FilePath = workingDir + "ExcelParameterScripting.wbpj") # Open Excel and the workbook ex = Excel.ApplicationClass() ex.Visible = True workbook = ex.Workbooks.Open(workingDir + "ParameterExample.xlsm") worksheet=workbook.ActiveSheet #Apply the update handler to the workbook button OLEbutton = worksheet.OLEObjects("CommandButton1") OLEbutton.Object.CLICK += updateHandler
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)