mil2n
Programmer
- Feb 28, 2005
- 4
I don’t know how to save a file using Excel application. Once I open the file it is read only and I am not able to save it.
Can someone help me with this problem?
Dim excelApp As New Excel.Application()
Dim excelBook As Excel.Workbook
excelBook = excelApp.Workbooks.Open(Path)
Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)
With excelWorksheet
.Range("A1").Value = "somethnig"
End With
Try
excelBook.SaveAs(Path) ' Here is the problem, opened file is read only and could not by saved
Catch ed As Exception
End Try
Try
excelWorksheet = Nothing
excelBook = Nothing
excelApp.Quit()
excelApp = Nothing
GC.Collect()
Can someone help me with this problem?
Dim excelApp As New Excel.Application()
Dim excelBook As Excel.Workbook
excelBook = excelApp.Workbooks.Open(Path)
Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)
With excelWorksheet
.Range("A1").Value = "somethnig"
End With
Try
excelBook.SaveAs(Path) ' Here is the problem, opened file is read only and could not by saved
Catch ed As Exception
End Try
Try
excelWorksheet = Nothing
excelBook = Nothing
excelApp.Quit()
excelApp = Nothing
GC.Collect()