Hello everyone,
I am having trouble putting the data from the array into the drop down list. I have a hashtable where the data is input from the array (comma delimited) correctly. But, when it goes to the next line of code, I get an error:
CurrentArray<error: an exception of type:{System.Runtime.InteropServices.COMException} occurred>Microsoft.Office.Interop.Excel.Range. Please, if someone can tell me why I'm getting this error, I'd appreciate it very much.
private void PutWkDateInXL()
{
DisableWorkSheetChanges = true;
int i;
try
{
ThisApplication.ScreenUpdating = false;
for (i = strWkEnd.GetLowerBound(0); i <= strWkEnd.GetUpperBound(0); i++)
{
strWkDate = strWkEnd[i].ToString();
// save the dates.
UpdateInfos = new UpdateInfo();
UpdateInfos.SetDate(strWkDate);
// add DATES to hashtable.
DateListHash.Add(UpdateInfos.GetDate(), UpdateInfos);
strDateList += UpdateInfos.GetDate() + ", ";
}
//the next line is where the error occurs
rngUC.get_Offset(0,0).Validation.Add(Excel.XlDVTyp e.xlValidateList,
Excel.XlDVAlertStyle.xlValidAlertStop,
Excel.XlFormatConditionOperator.xlBetween,
strDateList.ToString(),"");
rngUC.get_Offset(0,0).Validation.IgnoreBlank = true;
rngUC.get_Offset(0,0).Validation.InCellDropdown = true;
rngUC.get_Offset(0,0).Validation.InputMessage = strInputMessage;
rngUC.get_Offset(0,0).Validation.ShowInput = true;
rngUC.get_Offset(0,0).Value2 = strInputMessage;
}
finally
{
ThisApplication.ScreenUpdating = true;
DisableWorkSheetChanges = false;
}
}
*******(*)*******