W
WalangAlam
Guest
How to Rename Worksheet in excel through code?
Example Sheet1 to MyWorksheet using a code in VB.Net
Example Sheet1 to MyWorksheet using a code in VB.Net
yes rename one of the sheets inside that file. We have only one sheet in the excel file and i want to rename it using code.
Dim xlApp As Object = CreateObject("Excel.Application")
Dim xlBook As Object = xlApp.Workbooks.Open("c:\Test.xls")
xlBook.Worksheets(1).Name = xlBook.Name 'or any name you want
xlBook.Close(1)
xlApp.Quit()
Dim exc As New Application
Dim workbooks As Workbooks = exc.Workbooks
Dim workbook As Workbook = workbooks.Open("c:\Test.xls")
Dim sheets As Sheets = workbook.Worksheets
Dim worksheet As Worksheet = CType(sheets.Item(1), Worksheet)
worksheet.Name = "WOWThis is Cool"
Imports Microsoft.Office.Interop.Excel

