vb.net - COMException occurred - Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) when trying to modify an existing excel file -
3rd line returns comexception. obooks.gettype().invoke...
dim obooks microsoft.office.interop.excel.workbook = me.fopenxlsfile(strxlsfile) dim ci system.globalization.cultureinfo = new system.globalization.cultureinfo("en-us") obooks.gettype().invokemember("add", reflection.bindingflags.invokemethod, nothing, obooks, nothing, ci) int32 = 0 objlv.items.count - 1 obooks.styles.item(i + 1).interior.color = objlv.items(i).backcolor next obooks.save()
you're trying add workbook workbook. need add workbooks collection. should work:
dim wbs excel.workbooks = obooks.application.workbooks wbs.gettype().invokemember("add", reflection.bindingflags.invokemethod, nothing, wbs, nothing, ci)
Comments
Post a Comment