#  Other Applications & Softwares  > PowerPoint Formatting & General >  >  pb with [VBA] saveas instruction in Macro

## Mahler

Hello Everybody,

First i apologize for my english.... I need your help

I built a powerpoint with graphics linked to an excel file. Now I want to generate several powerpoint file linked to different excel files.

But for each file the vba execution stopped at saveas instruction with this message in french sorry "La méthode 'SaveAs' de l'objet '_Presentation' a échoué." and if i do in manual mode there 's no problem after.

Where is my mystake ?

Thank you for your help, i'm desesperate

----------


## Greg M

Hi there,

I tested your workbooks/presentations and the application seemed to work perfectly on my installation.

The only suggestion I can make is to change the following statement:




```
Please Login or Register  to view this content.
```


to:




```
Please Login or Register  to view this content.
```


This uses a "hard-coded" value for the FileFormat rather than the PowerPoint constant value.

Hope this helps - please let me know how you get on.

Regards,

Greg M

----------


## Mahler

Hi all,

so I use your suggestion and I still have the problem, so I add some wait() instruction:

like this

Sub maj(Fichier)


Dim Prez As PowerPoint.Presentation
Dim targetMaj As String
Dim Forme As PowerPoint.Shape
Dim Diapo As PowerPoint.Slide
Dim dossierpp As String
Dim newpres As String

  Oldfich = "Entreprise_12345"
  Newfich = Left(Fichier, Len(Fichier) - 5)
  newpres = Left(Newfich, 13) & "pres.pptx"
  'Application.DisplayAlerts = False
Presentation = "d:\DATA\first.pptx"

 dossierpp = "d:\DATA\fic_ppt\" & newpres
Application.Wait (Now() + TimeValue("00:00:04"))

Set pwrPoint = CreateObject("PowerPoint.Application")
pwrPoint.Visible = True


Set Prez = pwrPoint.Presentations.Open(Presentation)


For Each Diapo In Prez.Slides

    For Each Forme In Diapo.Shapes
        '
        If Forme.Type = msoLinkedOLEObject Then

            If Left(Forme.OLEFormat.progID, 11) = "Excel.Sheet" Then
                oldlink = Forme.LinkFormat.SourceFullName

                             newlink = Replace(oldlink, Oldfich, Newfich, , , vbDatabaseCompare)

                              Forme.LinkFormat.SourceFullName = newlink
                              Forme.LinkFormat.Update
                              Forme.LinkFormat.BreakLink


        End If
    End If
    Next
Next
 'nouveaunom = dossierpp
Application.Wait (Now() + TimeValue("00:00:04"))

Prez.SaveAs Filename:=dossierpp, FileFormat:=11

'ActiveWorkbook.SaveAs "C:\ron.xlsm", FileFormat:=52





Prez.Close
Set Prez = Nothing
Application.DisplayAlerts = True

pwrPoint.Quit
End Sub

----------


## Greg M

Hi there,

I've rewritten your routines and they seem to work correctly on my installation.

The code uses your folders D:\Data, fic_excel, and fic_ppt

The location of the "start folder" (D:\DATA) and the name of the original linkfile (Entreprise_12345) used in the PowerPoint template are specified in named ranges on the "Feuil1" worksheet.

The VBA code used is as follows:




```
Please Login or Register  to view this content.
```



Hope this helps - please let me know how you get on.

Regards,

Greg M

----------


## Mahler

Hi Greg,

it's very interesting , i will try it immediately . I'm going to change my code with yours .

thanks a lot  :Smilie:

----------


## Mahler

So my problem is now resolved , thanks all for your help.

----------


## Greg M

Hi again,

Many thanks for your feedback - glad I was able to help.

Best regards,

Greg M

----------

