Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I try to write some values from textboxes to excel, but I have a problem with DLL library:
Severity	Code	Description	Project	File	Line	Suppression State
Warning		Could not determine the dependencies of the COM reference "Microsoft.Office.Interop.Excel". Chyba při načítání knihovny typů či DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))	V2Solution

I dont known where is a problem, 0 errors, 1 warnings.	Thank you		


What I have tried:

My code:
<pre>Public Shared Sub updatelog()


        Dim formattedDate As String = Date.Today.ToString("dd/MM/yyyy")

        Dim OnlyTime As String = DateTime.Now.ToString("HH:mm:ss")
        Dim cislod As String
        cislod = iMontix.TextBox1.Text
        Dim zakazc As String
        zakazc = iMontix.TextBox2.Text
        Dim stav As String
        stav = "OK"
        Dim ID = iMontix.TextBox6.Text
        Dim kod_operace = iMontix.TextBox8.Text
        Dim smena = iMontix.TextBox5.Text
        Dim filename = "C:\_Montix a.s. - cloud\iMontix\logfile_V1.xls"
        Dim sheetname = "V1"

        If IO.File.Exists(filename) Then
            Dim Proceed As Boolean = False
            Dim xlApp As Excel.Application = Nothing
            Dim xlWorkBooks As Excel.Workbooks = Nothing
            Dim xlWorkBook As Excel.Workbook = Nothing
            Dim xlWorkSheet As Excel.Worksheet = Nothing
            Dim xlWorkSheets As Excel.Sheets = Nothing
            Dim xlCells As Excel.Range = Nothing

            xlApp.DisplayAlerts = False
            xlWorkBooks = xlApp.Workbooks
            xlWorkBook = xlWorkBooks.Open(filename)
            xlApp.Visible = True
            xlWorkSheets = xlWorkBook.Sheets
            For x As Integer = 1 To xlWorkSheets.Count
                xlWorkSheet = CType(xlWorkSheets(x), Excel.Worksheet)
                If xlWorkSheet.Name = sheetname Then
                    Console.WriteLine(sheetname)
                    Proceed = True
                    Exit For
                End If
                Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkSheet)
                xlWorkSheet = Nothing
            Next
            If Proceed Then

                xlWorkSheet.Range(xlWorkSheet.Cells(2, 2)).Value = cislod
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 3)).Value = zakazc
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 4)).Value = stav
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 5)).Value = formattedDate
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 6)).Value = OnlyTime
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 7)).Value = ID
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 8)).Value = smena
                xlWorkSheet.Range(xlWorkSheet.Cells(2, 9)).Value = kod_operace
                'save changes
                xlWorkBook.Save()

                xlWorkSheet.Activate()

            Else
                MessageBox.Show(sheetname & " not found.")
            End If
        Else
            MessageBox.Show("'" & filename & "' not located. Try one of the write examples first.")
        End If
    End Sub
Posted
Comments
CHill60 27-Jun-18 4:44am    
Sounds like the COM library you are trying to use is not properly installed. Try reinstalling Office and make sure you are referencing the correct version in your project
[no name] 27-Jun-18 4:48am    
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll
CHill60 27-Jun-18 5:35am    
What?
Make sure it is installed correctly - the easiest way is probably to reinstall Office. What using statements do you have in your project

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900