+ Reply to Thread
Results 1 to 3 of 3

Need 2013 Binding that works for 2010

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2009
    Location
    USA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    75

    Need 2013 Binding that works for 2010

    Hello,

    I created a 2010 app that created a PowerPoint after complete of the area of Excel needed. The problem is a user opened it up on his computer in 2013 and saved so the Microsoft PowerPoint 14.0 Object Library auto updated to 15.0 so when decided to run in 2010 it failed now..


    Sub MakeSlides1()
    'Dim password As Variant
    'password = Application.InputBox("Enter Password", "Password Protected")
    'Select Case password
    '    Case Is = False
    '        'do nothing
     '   Case Is = "PTACCESS"
    '        Range("A1").Value = "This is secret code"
    '    Case Else
    '        MsgBox "Incorrect Password"
    'End Select
        Dim mydata As Excel.Range
        Dim Sheet1 As Excel.Worksheet
        Dim Output As Workbook
        Dim WorkbookName As String
        Dim WorksheetName As String
        Dim PowerPointName As String
        Set Sheet1 = ActiveWorkbook.Sheets("PT DECK")
        'Set mydata = sheet1.Range("A35:S69")
        'mydata.Copy
        'Range("A35:R69").CopyPicture
        Dim pptApp As New PowerPoint.Application
        pptApp.Visible = True
        pptApp.Activate
        Dim pptPres As PowerPoint.Presentation
        Set pptPres = pptApp.Presentations.Add
        Sheets("PT DECK").Select
    'SLIDE 1
        Dim pptSlide As PowerPoint.Slide
        Set pptSlide = pptPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank)
        pptSlide.Select
        Range("B35:T69").CopyPicture 'Excel Cells not really a picture..
        pptSlide.Shapes.Paste.Select
        'Adjusting the Top and Bottom, trying to fix it on the paper
        pptApp.ActiveWindow.Selection.ShapeRange.Top = 45
        pptApp.ActiveWindow.Selection.ShapeRange.Height = 540
        pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
        pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
        Application.ScreenUpdating = True
    
    'ETC some saving code
    
    End Sub
    I'm reading and they saying to do Object something like this below, maybe some knows how.
    So like to delete the Object library and do it in all code..

        'Dim pptApp As Object
        'Set pptApp = CreateObject("PowerPoint.Application")
        'pptApp.Visible = True
        'pptApp.Activate
        
        'Dim pptPres As Object
        'Set pptPres = CreateObject("PowerPoint.Presentation")
        
        'Dim pptSlide As Object
        'Set pptPres = CreateObject("PowerPoint.Slide")
    MBCMDR
    Last edited by MBCMDR; 09-02-2015 at 01:05 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Need 2013 Binding that works for 2010

    I think what you are looking for is late-binding.

    That would look something like this, which is untested.
    Option Explicit
    
    Sub MakeSlides1()
        'Dim password As Variant
        'password = Application.InputBox("Enter Password", "Password Protected")
        'Select Case password
        '    Case Is = False
        '        'do nothing
        '   Case Is = "PTACCESS"
        '        Range("A1").Value = "This is secret code"
        '    Case Else
        '        MsgBox "Incorrect Password"
        'End Select
    Dim mydata As Excel.Range
    Dim Sheet1 As Excel.Worksheet
    Dim Output As Workbook
    Dim WorkbookName As String
    Dim WorksheetName As String
    Dim PowerPointName As String
    
    Dim pptApp As Object
    Dim pptPres As Object
    Dim pptSlide As Object
    
    Const ppLayoutBlank = 12
    
        Set Sheet1 = ActiveWorkbook.Sheets("PT DECK")
    
        Set pptApp = CreateObject("PowerPoint.Application")
    
        pptApp.Visible = True
        pptApp.Activate
    
        Set pptPres = pptApp.Presentations.Add
    
        'SLIDE 1
    
        Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
    
        pptSlide.Select
    
        Sheet1.Range("B35:T69").CopyPicture    'Excel Cells not really a picture..
    
        pptSlide.Shapes.Paste.Select
        'Adjusting the Top and Bottom, trying to fix it on the paper
        pptApp.ActiveWindow.Selection.ShapeRange.Top = 45
        pptApp.ActiveWindow.Selection.ShapeRange.Height = 540
        pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
        pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
        Application.ScreenUpdating = True
    
        'ETC some saving code
    
    End Sub
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-23-2009
    Location
    USA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    75

    Re: Need 2013 Binding that works for 2010

    Thank you.. I kept working on it and came up with this and it works but sure can still clean it up a bit...
    The only problem now as it works both 2013 & 2010 but the background paper width is less in 2010 and need to figure how to set margin.

    Dim ppApp As Object
    Dim ppSlide As Object
    Dim Output As Workbook
    Dim SheetName As String
    Dim TestRange As Range
    Dim TestSheet As Worksheet
    Dim WorkbookName As String
    Dim WorkSheetName As String
    Dim Sheet1 As Excel.Worksheet
    Dim PasteRange As Boolean
    Dim RangePasteType As String
    Dim RangeName As String
    Dim AddSlidesToEnd As Boolean
    Set Sheet1 = ActiveWorkbook.Sheets("PT DECK")
    
    On Error GoTo 0
    'Look for existing instance
    On Error Resume Next
    Set ppApp = GetObject(, "PowerPoint.Application")
    
    'If not available create
    If Err.Number <> 0 Then
    Set ppApp = CreateObject("PowerPoint.Application")
    End If
    On Error GoTo 0
    
    ' Paste Image 1---------------------------------------------------------
    'Add a presentation if none exists
    If ppApp.Presentations.Count = 0 Then ppApp.Presentations.Add
    'Make the instance visible
    ppApp.Visible = True
    'Check that a slide exits, if it doesn't add 1 slide. Else use the last slide for the paste operation
    If ppApp.ActivePresentation.Slides.Count = 0 Then
    Set ppSlide = ppApp.ActivePresentation.Slides.Add(1, 12) 'ppLayoutBlank
    Else
    If AddSlidesToEnd Then
    'Appends slides to end of presentation and makes last slide active
    ppApp.ActivePresentation.Slides.Add ppApp.ActivePresentation.Slides.Count + 1, 12 ' ppLayoutBlank
    ppApp.ActiveWindow.View.GotoSlide ppApp.ActivePresentation.Slides.Count
    Set ppSlide = ppApp.ActivePresentation.Slides(ppApp.ActivePresentation.Slides.Count)
    Else
    'Sets current slide to active slide
    Set ppSlide = ppApp.ActiveWindow.View.Slide
    End If
    End If
    
    On Error Resume Next
    Sheets("PT DECK").Select
    'Worksheets("Powerpoint").Range("AO1").Value = SlideTitle
    Worksheets("PT DECK").Range("B35:T69").CopyPicture
    'ppSlide.Shapes.PasteSpecial(ppPasteMetafilePicture).Select
    ppSlide.Shapes.Paste.Select
    'Center pasted object in the slide
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
    ppApp.ActiveWindow.Selection.ShapeRange.Top = 45
    'ppApp.ActiveWindow.Selection.ShapeRange.Width = 541
    ppApp.ActiveWindow.Selection.ShapeRange.Height = 540
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
    On Error GoTo 0
    
    ' Paste Image 2---------------------------------------------------------
    'Check that a slide exits, if it doesn't add 1 slide. Else use the last slide for the paste operation
    If ppApp.ActivePresentation.Slides.Count = 1 Then
    Set ppSlide = ppApp.ActivePresentation.Slides.Add(2, 12) 'ppLayoutBlank
    Else
    If AddSlidesToEnd Then
    'Appends slides to end of presentation and makes last slide active
    ppApp.ActivePresentation.Slides.Add ppApp.ActivePresentation.Slides.Count + 2, 12 ' ppLayoutBlank
    ppApp.ActiveWindow.View.GotoSlide ppApp.ActivePresentation.Slides.Count
    Set ppSlide = ppApp.ActivePresentation.Slides(ppApp.ActivePresentation.Slides.Count)
    Else
    'Sets current slide to active slide
    Set ppSlide = ppApp.ActiveWindow.View.Slide
    End If
    End If
    ppApp.ActiveWindow.View.GotoSlide ppApp.ActivePresentation.Slides.Count
    On Error Resume Next
    
    Sheets("PT DECK").Select
    'Worksheets("Powerpoint").Range("AO1").Value = SlideTitle
    Worksheets("PT DECK").Range("B71:T105").CopyPicture
    'ppSlide.Shapes.PasteSpecial(ppPasteMetafilePicture).Select
    ppSlide.Shapes.Paste.Select
    'Center pasted object in the slide
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
    ppApp.ActiveWindow.Selection.ShapeRange.Top = 45
    'ppApp.ActiveWindow.Selection.ShapeRange.Width = 541
    ppApp.ActiveWindow.Selection.ShapeRange.Height = 540
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
    On Error GoTo 0
    
    ' Paste Image 3-

+ 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. Macro button works for 2010 users, but not 2013
    By jspatten in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2015, 03:11 PM
  2. Replies: 0
    Last Post: 06-08-2015, 03:07 PM
  3. Code works for outlook 2010 but not 2013
    By Legend Rubber in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2015, 05:00 PM
  4. Excel 4.0 macro works in 2010 but is broken in 2013
    By gregsedwards in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2014, 05:48 PM
  5. Excel 2007 works but not 2010 or 2013
    By Miliano in forum Excel General
    Replies: 1
    Last Post: 10-02-2014, 03:20 AM
  6. [SOLVED] Macro works in 2010&2013 but not Excel 2003
    By Mattiac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-06-2014, 03:12 AM
  7. Late Binding VBA Issue from 2013 PPT to 2010
    By cgermanjr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 02:23 PM

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