c# - Exception from HRESULT: 0x800A03EC INDIRECT -


I am trying to run the indirect function Excel from C #. I used the following code but got an exception

"System's first chance exception system '. Runtime. Interp Services. COMException' System. Done in Dynamic Dile '

additional information: exception from HRESULT: 0x800A03EC

  Excel.Range vehicle_makes_dropdown = xlWorkSheet1.get_Range ( "B2", "B101"); Vehicle_makes_dropdown.formula = "= iNDIRECT (A2 ) "; Vehicle_makes_dropdown.Validation.Add (Excel.XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertInformation, XlFormatConditionOperator.xlEqual, vehicle_makes_dropdown.formula, MySQL); Vehicle_makes_dropdown.Validation.IgnoreBlank = true; Vehicle_makes_ Dropdown.Validation.InCellDropdown = true;  

is an updated code

  Microsoft.Office.Interop.Excel.Application application = new Microsoft.Office. Interop.Excel.Application (); Microsoft.Office.Interop.Excel.Workbook wlb = app.Workbooks.Open (@ "D: \ Templates2.xlsx"); Microsoft.Office.Interop.Excel.Worksheet MySheet = (Microsoft. Office.Interop.Excel.Worksheet) wlb.Sheets [1]; Microsoft.Office.Interop.Excel.Range oRange; // Get the subject // string subjetcs = string.Empty; // from the list & lt; Subject & gt; Lstsubject = Public Search (excluding gadgets); AdminQuestionCommonModel objAdminQuestioncommonModel = new AdminQuestionCommonModel (); // _ questions. Bind quiz dropdown (objAdminQuestioncommonModel); ObjAdminQuestioncommonModel.ExcelTopics = _Question.GetTopics (topic id); & Lt; SubjectBO & gt; LstTopics = GlobalService.GetAllTopicsandSubtopics (5, subject id, 0); // Get all topics in the topic // If (lstsubject.Count> 0) if (lstTopics.Count> 0) {Microsoft.Office.Interop.Excel.Worksheet IDSheet = (Microsoft.Office.Interop. Excel.Worksheet) wlb.Sheets [2]; Int rows = 1; Int Subway = 1; IDSheet.Unprotect ("123 #"); // foreach (var item in lstsubject) foreach (var topic lstTopics) {var TopicName = Topic.Topic_SubTopic.Trim (); Replacement ("", "_"). Change ("__", "_"); // Add the first through the header ID sheet. Seals [Rows, 1] = Subject. Shakti Tip ID ToString (); IDSheet.Cells [Rows, 2] = Subject Name; // list & lt; SubTopics & gt; Lst = PickSubTopic (item.TopicName, item.TopicID); & Lt; SubjectBO & gt; Lstsubtopics = _Question.GetSubTopics (Subject ID, Subject. SubjectTopicId); Int startindex = Mercury; Forresh (various sub-topics in Listboxics) {IDSheet.Cells [subrows, 4] = subtexics. Topic Sybotopic; IDSheet.Cells [subrows, 5] = subtopics.SubjectTopicId.ToString (); IDSheet.Cells [subrows, 6] = Subject Name; IDSheet.Cells [alien, 7] = subject. SubjectTopicId.ToString (); Subrows ++; } If (lstTopics.Count & gt; 0) {wlb.Names.Add (subject, name, IDSheet.get_Range ("D" + startindex + ": D" + (alarca-1)); } Subro ++; Rows ++; } Wlb.Names.Add ("Subject", IDSheet.get_Range ("B1: B" + (Rows-1)); Microsoft.Office.Interop.Excel.Range Range = MySheet.get_Range ("B2", "B800" ); Range.Validation.Delete (); range. Nmberformet = "text"; //Range.Cells.Value = lstsubject [0] .TopicName.ToString (); range. Cells.Value = "text"; range. Validation Kjoden (Maikrosoftkofiskintrp.akssel.aksdieltivipi.akselveelaidetait, Microsoft. Ofiskintrop.akssel. Akseldivielartstail. Akselelitstop, Microsoft. Ofiskintrop.akssel.aksafformetkand Isnopretr. Akselbitivin, Formula 1 "= Topics"); Renjkvadhanikta. Inseldropdaun = true; range. Legitimacy. Agyatbalik = true; ORange = MySheet.get_Range ( "C2", "C-3"); oRange.Validation. delete (); Orenjknmberformt = "text"; Orenjkvelideshnkaed (Maikrosoftkofiskinterop.akselkcldwatypekkslwalidtelist, Maikrosoftkofiskinterop.akselkshldawalertstilekkslwalidlertstop, Maikrosoftkofiskinterop.aksel. XlFormatConditionOperator.xlBetween, Formula 1: "= Indirect (B2)"); ORange.Validation.InCellDropdown = true; ORange.Validation.IgnoreBlank = true; IDSheet.Protect ("123 #"); //Range.Validation.InCellDropdown = true; //Range.Interior.Color = System.Drawing.ColorTranslator.ToOle (System.Drawing.Color.FromArgb (255, 217, 217, 0)); App.Visible = true; } You have to put double quotation marks around your cell reference inside the formula: << code>   

vehicle_max_dropdown.formula = "= indirect (" A2 ")";


Comments