Sub excel_kaydet()
Dim a As New SaveFileDialog
a.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
a.Title = "Excel’e Export Et"
a.Filter = "Excel Dosyaları | *.xlsx"
'-------------------------------------------
a.FileName = "AccessTr.Net.xls"
'-------------------------------------------
If a.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim ExcelApp As Excel.Application
Dim ExcelWorkbook As Excel.Workbook
Dim ExcelSheet As Excel.Worksheet
Dim MyFileName As String = Nothing
MyFileName = a.FileName
ExcelApp = CreateObject("Excel.Application")
ExcelWorkbook = ExcelApp.Workbooks.Add
ExcelSheet = ExcelWorkbook.Worksheets(1)
ExcelSheet.Cells(1, 1).Value = "Adı"
ExcelSheet.Cells(1, 2).Value = "Soyadı"
ExcelSheet.Cells(2, 1).Value = TextBox2.Text
ExcelSheet.Cells(2, 2).Value = TextBox3.Text
ExcelWorkbook.SaveAs(MyFileName) 'örneğin dosya adı = "deneme" olacak. KAYIT EDECEĞİM DOSYA ADINI SANIRIM BURALARA BİR YERE YAZACAĞIZ AMA NEREYE
ExcelWorkbook.Save()
ExcelWorkbook.Close()
ExcelApp.Quit()
MsgBox("Excel Dosyası Oluşturuldu", MsgBoxStyle.Information, "Bilgi")
End If
End Sub
Filename özelliği ile belirtebilirsiniz. Sizin kodunuza yaptığım eklemeyi yukarıda inceleyebilirsiniz.