Consulting

Results 1 to 6 of 6

Thread: Solved: VBA to Save PowerPoint

  1. #1
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location

    Solved: VBA to Save PowerPoint

    The following code was borrowed from another workbook and was working but for some reason it now fails with a Compile Error - it highlights the word "Date" in the "fNamef =" line.

    Any ideas why this no longer works?

    Thanks...

    JimS

    [vba]
    Sub Save_PPT()

    Dim oPPTApp As PowerPoint.Application
    Dim oPPTFile As PowerPoint.Presentation
    Dim sPath, fName1, fNamef As String

    sPath = "C:\MyData1 \"
    fName1 = "Sample_Data"
    fNamef = fName1 & "_" & Format(Date, "mmm-dd-yyyy") & "_" & Format(Time, "hh-mm-ss") & ".ppsm"

    Set oPPTApp = CreateObject("PowerPoint.Application")
    oPPTApp.Visible = msoTrue

    Set oPPTFile = oPPTApp.ActivePresentation

    oPPTApp.Visible = msoTrue

    oPPTFile.SaveAs Filename:=sPath & fNamef, FileFormat:=ppSaveAsDefault

    oPPTFile.Close
    oPPTApp.Quit

    End Sub
    [/vba]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I don't know why Date is failing, but why not just use

    [vba]

    fNamef = fName1 & "_" & Format(Now, "mmm-dd-yyyy hh-mm-ss") & ".ppsm"[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    Now it fails on the word "Format".

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    In the VBIDE, go to Tools>References. If there is a MISSING item, uncheck it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    That did it - THANKS...

    Not sure how the particualr missing item was affecting this part of the code, but it's fixed is all I care about (for now)...

    Thanks again...

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It's a bug/feature, VBA handles it incorrectly.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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