PDA

View Full Version : [SOLVED:] Adding the date to the filename



RayKay
07-19-2019, 06:03 AM
Hi John

With this code, it works great saving selected slides as Save As with the same file name as the original file, but I'm trying to add the date. Assuming the Opened file is called MySlides.pptx

[ORIGINAL PERFECT CODE]
Call NewPPT.SaveAs("C:\MyFolder" & OldPPT.Name)
[/CODE]

However, when I edit this to add the date:

[NEW CODE]
Call NewPPT.SaveAs("C:\MyFolder" & OldPPT.Name & Format(Date, " dd-mm-yy"))
[/CODE]

The filename becomes: MySlides.pptx 19-07-19.pptx

I've tried all sorts to remove the .pptx in the middle of the filename.

Thank you in advance :)

John Wilson
07-20-2019, 12:39 AM
Here's how to remove the suffix


Sub killsuffix()
Dim oldPPTName As String
Dim oldNameOnly As String
Dim ipos As Integer
oldPPTName = ActivePresentation.Name
ipos = InStrRev(oldPPTName, ".")
'check for suffix in case not saved
If ipos > 0 Then
oldNameOnly = Left(oldPPTName, ipos - 1)
MsgBox oldNameOnly
End If
End Sub