Make PowerPoint macro SaveAs overwrite without warning popup


New Member
Jun 7, 2019

is it possible to write a code to Excel VBA that saves a PowerPoint presentation to SharePoint with a dynamic name (changes according to a specific cell value) and overwrites the existing file, if there is one? This is my code now, and it doesn't work.

Application.DisplayAlerts = False

Dim path, newfname, frmt As String
path = "https:\\\sites\sales" '<-- the folder
newfname = wsdata.Range("L3") '<-- cell that the file name comes from
frmt = VBA.Right(ppt_pres.Name, 4) '<-- i think this is the fileformat pptx

If newfname <> False Then

If Not Dir(newfname) <> "" Then
ppt_pres.SaveAs Filename:=newfname
On Error Resume Next

If Err.Number = 1004 Then
On Error GoTo 0
ppt_pres.SaveAs Filename:=mypath & newfname & frmt & ".pptx", _
FileFormat:=ppSaveAsOpenXMLPresentation, _

End If
End If
End If

Application.DisplayAlerts = True

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.


Well-known Member
May 24, 2005
Application.DisplayAlerts = False
should suppress the warning.

Perhaps use
On Error Resume Next
KILL mypath & newfname & frmt & ".pptx"
On Error GoTo 0
just prior to the save statement

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...