Here is some code I found. There is a part where you can open an excel file. I would suggest opening the templated excel worksheet or workbook and then do your adjustments and then sanve it as something else.
VB Code:
Module Module1 Const SourceExcelFileName = "C:\vbnet\source.xls" Sub Main() On Error Resume Next Dim oExcel As Excel.ApplicationClass Dim oBook As Excel.WorkbookClass Dim oBooks As Excel.Workbooks 'Start Excel and open the workbook. oExcel = CreateObject("Excel.Application") oExcel.Visible = True oBooks = oExcel.Workbooks oBook = oBooks.Open(SourceExcelFileName) ' oBook.SaveAs("C:\FolderName\SaveFilename.XML",Excel.XlFileFormat.xlXMLSpreadsheet) oBook.SaveAs("C:\vbnet\SaveFilename.xls") 'Clean-up: Close the workbook and quit Excel. oBook.Close(False) System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook) oBook = Nothing System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks) oBooks = Nothing oExcel.Quit() System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel) oExcel = Nothing Exit Sub End Sub End Module




Reply With Quote