Consulting

Results 1 to 2 of 2

Thread: Adding the date to the filename

  1. #1
    VBAX Regular
    Joined
    Dec 2018
    Posts
    89
    Location

    Adding the date to the filename

    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

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,843
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •