gsf
gsf

Reputation: 7262

programmatically renaming excel worksheet without API

I am working on a project that does not depend on any MS API for open xml documents manipulation (this not a subject of change).

I need to be able to rename a sheet name in a arbitrary excel file.

Can somebody refer me to a page where all the possible references of a worksheet name are listed.

Upvotes: 0

Views: 449

Answers (1)

Gary's Student
Gary's Student

Reputation: 96791

If your programming environment is Excel VBA, then your macro could:

  1. open the arbitrary file
  2. re-name the worksheet
  3. save the arbitrary file
  4. close the arbitrary file

For example:

Sub Macro1()
    Workbooks.Open Filename:="C:\TestFolder\ABC.xls"
    Sheets(1).Name = "NewName"
    ActiveWorkbook.Save
    ActiveWorkbook.Close
End Sub

Upvotes: 1

Related Questions