VBA: Rename File When Excel is still/Keep Opening
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 574
- Joined: 14 Nov 2012, 16:06
Re: VBA: Rename File When Excel is still/Keep Opening
You can use this code in any Workbook.
You can use a file containing this code as a template for any new workbook.
You can use a file containing this code as a template for any new workbook.
Code: Select all
Private Sub Workbook_Open()
c00 = CreateObject("scripting.filesystemobject").getbasename(ThisWorkbook.FullName)
ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & IIf(InStr(c00, "_"), Left(c00, InStr(c00, "_")) & Format(Val(Right(c00, 3)) + 1, "000"), c00 & "_000"), ThisWorkbook.FileFormat
End Sub
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA: Rename File When Excel is still/Keep Opening
Susant wrote that they want to use the code in an add-in.
Best wishes,
Hans
Hans