public void Function_Click(IRibbonControl control_) { Xl.Application xlApp = (Xl.Application)ExcelDna.Integration.ExcelDnaUtil.Application; String fname = control_.Id; fname = "=" + fname + "()"; Xl.Range rg = xlApp.ActiveCell; String cellName = ExcelUtil.ExcelColumnIndexToName(rg.Column) + rg.Row; Xl._Worksheet sheet = (Xl.Worksheet)xlApp.ActiveSheet; Xl.Range range = sheet.get_Range(cellName, System.Type.Missing); string previousFormula = range.FormulaR1C1.ToString(); range.Value2 = fname; range.Select(); syncContext_ = SynchronizationContext.Current; if (syncContext_ == null) { syncContext_ = new System.Windows.Forms.WindowsFormsSynchronizationContext(); } FunctionWizardThread othread = new FunctionWizardThread(range, syncContext_); Thread thread = new Thread(new ThreadStart(othread.functionargumentsPopup)); thread.Start(); }