private void bnFormatPinPointer_Click(CommandBarButton Ctrl, ref bool CancelDefault) { //MessageBox.Show("PinPointer Formatting..."); try { Excel.Range pinPointerSelection = (Excel.Range)excelApp.Selection; IList logEntries = new ArrayList(); for (int i = 1; i < pinPointerSelection.Rows.Count + 1; i++) { CallLogEntry cle = new CallLogEntry(); // Get Company name string companyName = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 1)).Text; companyName = companyName.Trim(); cle.CompanyName = companyName; // Get contact and title string contact = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 9)).Text; contact = contact.Trim(); string title = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 10)).Text; title = title.Trim(); cle.ContactAndTitle = contact + "/" + title; // Get phone + area string area = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 6)).Text; area = area.Trim(); string phone = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 7)).Text; phone = phone.Trim(); cle.PhoneNumber = area + "-" + phone; // IndustryAndEmployees // PRoduct: 13, Emp: 11 string product = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 13)).Text; product = product.Trim(); string emp = (string)((Excel.Range)pinPointerSelection.Rows.Cells.get_Item(i, 11)).Text; emp = emp.Trim(); cle.IndustryEmployeeCount = product + " " + emp; logEntries.Add(cle); } pinPointerSelection.Clear(); int row = 1; foreach (CallLogEntry c in logEntries) { ((Excel.Range)pinPointerSelection.Rows.Cells[row, 2]).Value2 = c.CompanyName; ((Excel.Range)pinPointerSelection.Rows.Cells[row, 3]).Value2 = c.ContactAndTitle; ((Excel.Range)pinPointerSelection.Rows.Cells[row, 4]).Value2 = c.PhoneNumber; ((Excel.Range)pinPointerSelection.Rows.Cells[row, 7]).Value2 = c.IndustryEmployeeCount; row++; } } catch (Exception ex) { MessageBox.Show("An exception occured during processing: " + ex.Message); } }