I created an Excel File which will serve as a database using the following code :
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
xlWorkSheet.Cells(1, 1) = "Name"
xlWorkSheet.Cells(1, 2) = "Institute Roll No."
xlWorkSheet.Cells(1, 3) = "Marks"
xlWorkSheet.SaveAs("D:\database.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MsgBox("Excel file created , you can find the file in D:\")
End Sub
It works and the file is created in D:\
What i want to know is how to use the SaveFileDialog to save the file at any location i want...?
This is my first time using vb.net and I'm a total newbie...so any help will be appreciated.
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
xlWorkSheet.Cells(1, 1) = "Name"
xlWorkSheet.Cells(1, 2) = "Institute Roll No."
xlWorkSheet.Cells(1, 3) = "Marks"
xlWorkSheet.SaveAs("D:\database.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MsgBox("Excel file created , you can find the file in D:\")
End Sub
It works and the file is created in D:\
What i want to know is how to use the SaveFileDialog to save the file at any location i want...?
This is my first time using vb.net and I'm a total newbie...so any help will be appreciated.