I im1dermike Jun 10, 2009 #1 I'm writing a C# program where I need to go through a loop and add a ComboBox to an Excel spreadsheet cell. How do I do this?
I'm writing a C# program where I need to go through a loop and add a ComboBox to an Excel spreadsheet cell. How do I do this?
I im1dermike Jun 11, 2009 #2 I figured it out. It's actually a DropDown object I'm interested in... protected static Excel.Application app; protected static Excel.Range range; protected static Excel.Workbook wb; protected static Excel.Sheets sheets; protected static Excel.Worksheet sheet; protected static object oMissing = Missing.Value; range = sheet.get_Range("N1", "N1"); Excel.DropDowns xlDropDowns; Excel.DropDown xlDropDown; xlDropDowns = ((Excel.DropDowns)(sheet.DropDowns(oMissing))); xlDropDown = xlDropDowns.Add((double)range.Left, (double)range.Top, (double)range.Width, (double)range.Height, true); //Add items into drop down list for (int i = 0; i < items.Length; i++) { xlDropDown.AddItem(items, i + 1); }
I figured it out. It's actually a DropDown object I'm interested in... protected static Excel.Application app; protected static Excel.Range range; protected static Excel.Workbook wb; protected static Excel.Sheets sheets; protected static Excel.Worksheet sheet; protected static object oMissing = Missing.Value; range = sheet.get_Range("N1", "N1"); Excel.DropDowns xlDropDowns; Excel.DropDown xlDropDown; xlDropDowns = ((Excel.DropDowns)(sheet.DropDowns(oMissing))); xlDropDown = xlDropDowns.Add((double)range.Left, (double)range.Top, (double)range.Width, (double)range.Height, true); //Add items into drop down list for (int i = 0; i < items.Length; i++) { xlDropDown.AddItem(items, i + 1); }
I im1dermike Jun 11, 2009 #3 I figured it out. It's actually a DropDown object I'm interested in... protected static Excel.Application app; protected static Excel.Range range; protected static Excel.Workbook wb; protected static Excel.Sheets sheets; protected static Excel.Worksheet sheet; protected static object oMissing = Missing.Value; range = sheet.get_Range("N1", "N1"); Excel.DropDowns xlDropDowns; Excel.DropDown xlDropDown; xlDropDowns = ((Excel.DropDowns)(sheet.DropDowns(oMissing))); xlDropDown = xlDropDowns.Add((double)range.Left, (double)range.Top, (double)range.Width, (double)range.Height, true); //Add items into drop down list for (int i = 0; i < items.Length; i++) { xlDropDown.AddItem(items, i + 1); }
I figured it out. It's actually a DropDown object I'm interested in... protected static Excel.Application app; protected static Excel.Range range; protected static Excel.Workbook wb; protected static Excel.Sheets sheets; protected static Excel.Worksheet sheet; protected static object oMissing = Missing.Value; range = sheet.get_Range("N1", "N1"); Excel.DropDowns xlDropDowns; Excel.DropDown xlDropDown; xlDropDowns = ((Excel.DropDowns)(sheet.DropDowns(oMissing))); xlDropDown = xlDropDowns.Add((double)range.Left, (double)range.Top, (double)range.Width, (double)range.Height, true); //Add items into drop down list for (int i = 0; i < items.Length; i++) { xlDropDown.AddItem(items, i + 1); }