I guess what my question is, what is VBAProject. Is VBAProject my Program.xlsm file because if I replace with that I get the same error.
I tried adding to find the name: Dim myString As String myString = ThisWorkbook.VBProject.Name But got a similar error
At the end of the day I am trying to change the CodeName of my Template Worksheet WS0000 to WS0002, WS0003... WS0nnn within my VBA code
Sub ChangeCodeName()
Dim wbk As Object, Sheet As Object
ActiveWorkbook.VBProject.Name = "VBAProject"
Set wbk = ActiveWorkbook.VBProject.VBComponents(ActiveWorkbook.CodeName)
wbk.Name = "WS0000"
Set Sheet = ActiveWorkbook.VBProject.VBComponents(ActiveWorkbook.Sheets(1).CodeName)
Sheet.Name = "WS0002"
End Sub
