You can program Visual Basic Editor (VBE) (actually it is funny I just answered this awhile ago).
Check it out to see how to add reference to VBA Extensibility Library.
Something like below should work for you once you've properly set up the required reference:
Dim VBProj As VBIDE.VBProject, wb as Workbook
Set wb = ThisWorkbook
Set VBProj = wb.VBProject
VBProj.VBComponents("Module1").Name = "Module2"
Important:
- Add reference to VBA Extensibility Library
Microsoft Visual Basic For Applications Extensibility 5.3
- Tick Trust access to the VBA project object model under Developer Macro Settings.

- Project should be unlocked.