Interop not writing in excel file and not releasing COM
Greetings fellow users and moderators.
I am using interop to write to excel but it seems that my project isn't writing that well into the excel file. I want to change a cell with "N" to "D" but the coding isn't right.
Code:
ElseIf check = "N" Then
xlWorkSheet.Cells(Int(Listnum.Items(numrent2)), 6) = "D"
End If
The listbox contains the row number in a string and changes it to integer.
Afterwards, I am not releasing my COM the right way... I've been informed that my release object is wrong.
Code:
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
Re: Interop not writing in excel file and not releasing COM
Found the answer! it was the order of object releasing!