VB.Net to Excel Problem
-
The following code works on my PC but when I try and run the exe on another PC I get the following message.... An unhandled exception has occurred in your application..... File or assembly name Interop.Excel, or one of it's dependencies, was not found. I added reference Microsoft Excel 8.0 Object Library Here is my code.... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyExcel As New Excel.Application 'Creating Excel Worksheet Dim WSheet As New Excel.Worksheet 'Adding new worksheet to excel workbooks WSheet = MyExcel.Workbooks.Add.Worksheets.Add 'Writing values in Work Sheet With WSheet 'Cells(row, column) .Cells(1, 1).Value = "TESTING " .Cells(2, 1).Value = "A" .Cells(2, 2).Value = "B" .Cells(2, 3).Value = "C" .Cells(2, 4).Value = "D" End With 'Saving .xls file with Test.xls name WSheet.SaveAs("C:\temp\aTEST.XLS") End Sub
-
The following code works on my PC but when I try and run the exe on another PC I get the following message.... An unhandled exception has occurred in your application..... File or assembly name Interop.Excel, or one of it's dependencies, was not found. I added reference Microsoft Excel 8.0 Object Library Here is my code.... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyExcel As New Excel.Application 'Creating Excel Worksheet Dim WSheet As New Excel.Worksheet 'Adding new worksheet to excel workbooks WSheet = MyExcel.Workbooks.Add.Worksheets.Add 'Writing values in Work Sheet With WSheet 'Cells(row, column) .Cells(1, 1).Value = "TESTING " .Cells(2, 1).Value = "A" .Cells(2, 2).Value = "B" .Cells(2, 3).Value = "C" .Cells(2, 4).Value = "D" End With 'Saving .xls file with Test.xls name WSheet.SaveAs("C:\temp\aTEST.XLS") End Sub
check if Excel 8.0 is installed on that m/c or some other previos verson is installed Divya Rathi