[ CORSA @ 22.12.2013. 07:41 ] @
Poštovani, Našao sam neki kod na net-u,al izbacuje mi grešku,pa bi molio da mi netko kaže što nije u redu. Code: Imports Microsoft.Office.Interop Public Class Form1 Dim objExcel As New Excel.Application Dim objWorkbook As Excel.Workbook Dim objWorksheet As Excel.Worksheet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load objWorkbook = objExcel.Workbooks.Open("d:\table.xlsx") objWorksheet = CType(objWorkbook.Worksheets.Item("Sheet1"), Excel.Worksheet) TextBox1.Text = objWorksheet.Cells(1, 1).text TextBox2.Text = objWorksheet.Cells(2, 1).text TextBox3.Text = objWorksheet.Cells(3, 1).text End Sub Private Sub Command1_Click() objWorksheet.Cells(1, 1).Value = TextBox1.Text objWorksheet.Cells(2, 3).Value = TextBox2.Text objWorksheet.Cells(3, 3).Value = TextBox3.Text End Sub Private Sub Command2_Click() objExcel.Application.Quit() End Sub Private Sub Command3_Click() objExcel.SaveAs("d:\table.xlsx") End Sub End Class greška u liniji " objWorksheet = CType(objWorkbook.Worksheets.Item("Sheet1"), Excel.Worksheet)" An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication5.exe Additional information: Indeks nije valjan. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) |