+ Reply to Thread
Results 1 to 7 of 7

pb with [VBA] saveas instruction in Macro

  1. #1
    Registered User
    Join Date
    11-13-2015
    Location
    France
    MS-Off Ver
    10.0
    Posts
    4

    Unhappy pb with [VBA] saveas instruction in Macro

    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
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2013
    Posts
    3,458

    Re: pb with [VBA] saveas instruction in Macro

    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

  3. #3
    Registered User
    Join Date
    11-13-2015
    Location
    France
    MS-Off Ver
    10.0
    Posts
    4

    Re: pb with [VBA] saveas instruction in Macro

    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

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2013
    Posts
    3,458

    Re: pb with [VBA] saveas instruction in Macro

    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
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-13-2015
    Location
    France
    MS-Off Ver
    10.0
    Posts
    4

    Re: pb with [VBA] saveas instruction in Macro

    Hi Greg,

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

    thanks a lot

  6. #6
    Registered User
    Join Date
    11-13-2015
    Location
    France
    MS-Off Ver
    10.0
    Posts
    4

    Re: pb with [VBA] saveas instruction in Macro

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

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2013
    Posts
    3,458

    Re: pb with [VBA] saveas instruction in Macro

    Hi again,

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

    Best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with a macro generating a msgbox instruction
    By Johnb11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2014, 07:07 PM
  2. ignoring an instruction on a macro loop if folder already exists
    By Macro_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2014, 09:31 AM
  3. SaveAs Macro
    By bhenderson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2011, 12:04 AM
  4. Formating pivot table to accept macro instruction
    By rockinrandall in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-27-2010, 04:57 PM
  5. Add Instruction Code For NO or CANCEL within ActiveWorkbook.SaveAs
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2010, 04:20 PM
  6. Finding an instruction in a macro
    By Raiby in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-20-2007, 09:48 AM
  7. [SOLVED] Saveas Macro
    By Nigel in forum Excel General
    Replies: 3
    Last Post: 05-11-2005, 09:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1