Question

I'm kind of stuck on this code

I need a powerpoint macro which allows me to save all powerpoint files to a particular map with as name "name of presentation" + variable. Anybody a clue whats wrong with code below?

Sub save()

Dim i As Integer
Dim pptcount As Integer
Dim pres As Presentation
Dim var1 As String

Set pres = Application.Presentations(i)
var1 = InputBox("geef hier je maand aan")


pptcount = Application.Presentations.Count

For i = 1 To pptcount

    Application.ActivePresentation.SaveAs "X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\SENS referenten rapportage\Template_Uploaden\" & var1 & ".ppt"




Next

End Sub

Was it helpful?

Solution

Try this code:

Sub save()
    Dim pres As Presentation
    Dim var1 As String

    var1 = InputBox("geef hier je maand aan")
    If var1 <> "" Then
        For Each pres In Application.Presentations
            pres.SaveAs "X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\SENS referenten rapportage\Template_Uploaden\" & Split(pres.Name, ".")(0) & var1 & ".ppt"
        Next
    End If
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top