Results 1 to 2 of 2

Thread: Interop not writing in excel file and not releasing COM

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    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

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    Re: Interop not writing in excel file and not releasing COM

    Found the answer! it was the order of object releasing!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width