Hello everyone.. I want to chnage this code to use filedialog open.. Not declare the file in the procedure.. I want to chnage it to open anyworkbook
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
xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Open("c:\test1.xlsx")
xlWorkSheet = xlWorkBook.Worksheets("she
et1")
'display the cells value B2
MsgBox(xlWorkSheet.Cells(2
, 2).value)
'edit the cell with new value
xlWorkSheet.Cells(2, 2) = "
http://vb.net-informations.com"
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
End Sub
Then here is some code you can modify to suit your needs (it returns path\filename):
Open in new window
if what is returned is "" then exit the procedure. Otherwise, specify it to open instead of "c:\test1.xlsx" in xlWorkBook = xlApp.Workbooks.Open("c:\t