I have this code that allows me to export the data contained in the two TextBoxs in an excel spreadsheet, the problem is that the excel file is not created. I put the two statements are not working for rescuing comment below, maybe someone can test it and tell me why it is wrong.
Dim objExcel As New Excel.Application ' Represents an instance of Excel
Dim objWorkbook As Excel.Workbook 'Represents a workbook object
Dim objWorksheet As Excel.Worksheet 'Represents a worksheet object
objWorkbook = objExcel.Workbooks.Add
objWorksheet = CType(objWorkbook.Worksheets.Item(1), Excel.Worksheet)
'This form contains two text boxes, write values to cells A1 and A2
objWorksheet.Cells(1, 1) = TextBox1.Text
objWorksheet.Cells(2, 1) = TextBox2.Text
objWorkbook.Close(False)
'objWorkbook.Save()
'or
'objWorkbook.SaveAs("C:\Temp\Book1.xls")
objExcel.Quit()
SaveAs()doesn't throw an error then the file should indeed be successfully saved. Are you sure it wasn't? Did you uncomment the "save" lines when you actually ran the code?