+ Reply to Thread
Results 1 to 5 of 5

Late Binding

  1. #1
    Mark
    Guest

    Late Binding

    At the present time I am using Excel 97, With the help of participants on
    this newsgroup and using Excel XP, I managed to put together some code which
    copied an excel spreadsheet into powerpoint.

    The following code worked fine on Excel XP but I needed it to work on all
    versions of Excel so I have now used Late Binding instead of referencing it.

    Unfortunately now I have done this I am getting debug errors on:

    ppLayoutText
    ppPasteMetafilePicture

    Can anyone help with a solution, please?

    Here is some of the code
    *****************

    Dim pptApp As Object
    Dim pptPres As Object
    Dim pptSlide As Object
    Dim pptShape As Object

    Set pptApp = CreateObject("PowerPoint.Application")
    Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new presentation
    ' or open an existing presentation
    ' Set pptPres = pptApp.Presentations.Open("C:\Foldername\Filename.ppt")

    ' apply a slide template
    pptPres.ApplyTemplate "C:\Program Files\Microsoft
    Office\Templates\Presentation Designs\Contemporary Portrait.pot"


    For Each asheet In ActiveWorkbook.Sheets
    ' only officer sheets visible at this point
    If asheet.Visible = True Then
    sheetname = asheet.Name
    Worksheets(sheetname).Activate

    With ActiveSheet
    .Shapes("Slide").Copy ' copy a picture from Excel

    With pptPres.Slides
    Set pptSlide = .Add(.Count + 1, ppLayoutText) ' add a slide
    End With

    With pptSlide

    .Shapes(1).Delete ' remove title
    '.Shapes(2).Delete ' remove the text box
    .Shapes.PasteSpecial ppPasteMetafilePicture

    With .Shapes(.Shapes.Count)
    .Left = 0
    .Top = 0
    .Width = 720
    .Height = 540
    End With
    End With
    End With
    End If
    Next asheet

    etc.....


  2. #2
    Bob Phillips
    Guest

    Re: Late Binding

    They are PowerPoint constants, and you cannot use constants from the OM in
    late binding.

    Replace by 2 and 3 respectively.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Mark" <[email protected]> wrote in message
    news:[email protected]...
    > At the present time I am using Excel 97, With the help of participants on
    > this newsgroup and using Excel XP, I managed to put together some code

    which
    > copied an excel spreadsheet into powerpoint.
    >
    > The following code worked fine on Excel XP but I needed it to work on all
    > versions of Excel so I have now used Late Binding instead of referencing

    it.
    >
    > Unfortunately now I have done this I am getting debug errors on:
    >
    > ppLayoutText
    > ppPasteMetafilePicture
    >
    > Can anyone help with a solution, please?
    >
    > Here is some of the code
    > *****************
    >
    > Dim pptApp As Object
    > Dim pptPres As Object
    > Dim pptSlide As Object
    > Dim pptShape As Object
    >
    > Set pptApp = CreateObject("PowerPoint.Application")
    > Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new

    presentation
    > ' or open an existing presentation
    > ' Set pptPres =

    pptApp.Presentations.Open("C:\Foldername\Filename.ppt")
    >
    > ' apply a slide template
    > pptPres.ApplyTemplate "C:\Program Files\Microsoft
    > Office\Templates\Presentation Designs\Contemporary Portrait.pot"
    >
    >
    > For Each asheet In ActiveWorkbook.Sheets
    > ' only officer sheets visible at this point
    > If asheet.Visible = True Then
    > sheetname = asheet.Name
    > Worksheets(sheetname).Activate
    >
    > With ActiveSheet
    > .Shapes("Slide").Copy ' copy a picture from Excel
    >
    > With pptPres.Slides
    > Set pptSlide = .Add(.Count + 1, ppLayoutText) ' add a

    slide
    > End With
    >
    > With pptSlide
    >
    > .Shapes(1).Delete ' remove title
    > '.Shapes(2).Delete ' remove the text box
    > .Shapes.PasteSpecial ppPasteMetafilePicture
    >
    > With .Shapes(.Shapes.Count)
    > .Left = 0
    > .Top = 0
    > .Width = 720
    > .Height = 540
    > End With
    > End With
    > End With
    > End If
    > Next asheet
    >
    > etc.....
    >




  3. #3
    Chip Pearson
    Guest

    Re: Late Binding

    Mark,

    ppLayoutText and ppPasteMetafilePicture are constants (symbolic
    names for numbers). You can't use constants unless you have a
    reference to the library which defines them. Since you don't have
    a reference to the PowerPoint library, you must use the actual
    numeric value rather than the constant name.

    Change
    ppLayoutText to 2
    ppPasteMetafilePicture to 3


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Mark" <[email protected]> wrote in message
    news:[email protected]...
    > At the present time I am using Excel 97, With the help of
    > participants on
    > this newsgroup and using Excel XP, I managed to put together
    > some code which
    > copied an excel spreadsheet into powerpoint.
    >
    > The following code worked fine on Excel XP but I needed it to
    > work on all
    > versions of Excel so I have now used Late Binding instead of
    > referencing it.
    >
    > Unfortunately now I have done this I am getting debug errors
    > on:
    >
    > ppLayoutText
    > ppPasteMetafilePicture
    >
    > Can anyone help with a solution, please?
    >
    > Here is some of the code
    > *****************
    >
    > Dim pptApp As Object
    > Dim pptPres As Object
    > Dim pptSlide As Object
    > Dim pptShape As Object
    >
    > Set pptApp = CreateObject("PowerPoint.Application")
    > Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new
    > presentation
    > ' or open an existing presentation
    > ' Set pptPres =
    > pptApp.Presentations.Open("C:\Foldername\Filename.ppt")
    >
    > ' apply a slide template
    > pptPres.ApplyTemplate "C:\Program Files\Microsoft
    > Office\Templates\Presentation Designs\Contemporary
    > Portrait.pot"
    >
    >
    > For Each asheet In ActiveWorkbook.Sheets
    > ' only officer sheets visible at this point
    > If asheet.Visible = True Then
    > sheetname = asheet.Name
    > Worksheets(sheetname).Activate
    >
    > With ActiveSheet
    > .Shapes("Slide").Copy ' copy a picture from
    > Excel
    >
    > With pptPres.Slides
    > Set pptSlide = .Add(.Count + 1, ppLayoutText) '
    > add a slide
    > End With
    >
    > With pptSlide
    >
    > .Shapes(1).Delete ' remove title
    > '.Shapes(2).Delete ' remove the text box
    > .Shapes.PasteSpecial ppPasteMetafilePicture
    >
    > With .Shapes(.Shapes.Count)
    > .Left = 0
    > .Top = 0
    > .Width = 720
    > .Height = 540
    > End With
    > End With
    > End With
    > End If
    > Next asheet
    >
    > etc.....
    >




  4. #4
    Mark
    Guest

    Re: Late Binding

    Thanks

    I have replaced pplayouttext to 2
    but
    pppastemetapicture to 3 doesn't seem to work, any ideas?

    .Shapes.PasteSpecial 3
    ' .Shapes.PasteSpecial ppPasteMetafilePicture


    --
    Mark


    "Chip Pearson" wrote:

    > Mark,
    >
    > ppLayoutText and ppPasteMetafilePicture are constants (symbolic
    > names for numbers). You can't use constants unless you have a
    > reference to the library which defines them. Since you don't have
    > a reference to the PowerPoint library, you must use the actual
    > numeric value rather than the constant name.
    >
    > Change
    > ppLayoutText to 2
    > ppPasteMetafilePicture to 3
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "Mark" <[email protected]> wrote in message
    > news:[email protected]...
    > > At the present time I am using Excel 97, With the help of
    > > participants on
    > > this newsgroup and using Excel XP, I managed to put together
    > > some code which
    > > copied an excel spreadsheet into powerpoint.
    > >
    > > The following code worked fine on Excel XP but I needed it to
    > > work on all
    > > versions of Excel so I have now used Late Binding instead of
    > > referencing it.
    > >
    > > Unfortunately now I have done this I am getting debug errors
    > > on:
    > >
    > > ppLayoutText
    > > ppPasteMetafilePicture
    > >
    > > Can anyone help with a solution, please?
    > >
    > > Here is some of the code
    > > *****************
    > >
    > > Dim pptApp As Object
    > > Dim pptPres As Object
    > > Dim pptSlide As Object
    > > Dim pptShape As Object
    > >
    > > Set pptApp = CreateObject("PowerPoint.Application")
    > > Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new
    > > presentation
    > > ' or open an existing presentation
    > > ' Set pptPres =
    > > pptApp.Presentations.Open("C:\Foldername\Filename.ppt")
    > >
    > > ' apply a slide template
    > > pptPres.ApplyTemplate "C:\Program Files\Microsoft
    > > Office\Templates\Presentation Designs\Contemporary
    > > Portrait.pot"
    > >
    > >
    > > For Each asheet In ActiveWorkbook.Sheets
    > > ' only officer sheets visible at this point
    > > If asheet.Visible = True Then
    > > sheetname = asheet.Name
    > > Worksheets(sheetname).Activate
    > >
    > > With ActiveSheet
    > > .Shapes("Slide").Copy ' copy a picture from
    > > Excel
    > >
    > > With pptPres.Slides
    > > Set pptSlide = .Add(.Count + 1, ppLayoutText) '
    > > add a slide
    > > End With
    > >
    > > With pptSlide
    > >
    > > .Shapes(1).Delete ' remove title
    > > '.Shapes(2).Delete ' remove the text box
    > > .Shapes.PasteSpecial ppPasteMetafilePicture
    > >
    > > With .Shapes(.Shapes.Count)
    > > .Left = 0
    > > .Top = 0
    > > .Width = 720
    > > .Height = 540
    > > End With
    > > End With
    > > End With
    > > End If
    > > Next asheet
    > >
    > > etc.....
    > >

    >
    >
    >


  5. #5
    Chip Pearson
    Guest

    Re: Late Binding

    What do you mean by "doesn't seem to work"? You might want to ask
    your question in a PowerPoint group.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Mark" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks
    >
    > I have replaced pplayouttext to 2
    > but
    > pppastemetapicture to 3 doesn't seem to work, any ideas?
    >
    > .Shapes.PasteSpecial 3
    > ' .Shapes.PasteSpecial ppPasteMetafilePicture
    >
    >
    > --
    > Mark
    >
    >
    > "Chip Pearson" wrote:
    >
    >> Mark,
    >>
    >> ppLayoutText and ppPasteMetafilePicture are constants
    >> (symbolic
    >> names for numbers). You can't use constants unless you have a
    >> reference to the library which defines them. Since you don't
    >> have
    >> a reference to the PowerPoint library, you must use the actual
    >> numeric value rather than the constant name.
    >>
    >> Change
    >> ppLayoutText to 2
    >> ppPasteMetafilePicture to 3
    >>
    >>
    >> --
    >> Cordially,
    >> Chip Pearson
    >> Microsoft MVP - Excel
    >> Pearson Software Consulting, LLC
    >> www.cpearson.com
    >>
    >>
    >> "Mark" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > At the present time I am using Excel 97, With the help of
    >> > participants on
    >> > this newsgroup and using Excel XP, I managed to put together
    >> > some code which
    >> > copied an excel spreadsheet into powerpoint.
    >> >
    >> > The following code worked fine on Excel XP but I needed it
    >> > to
    >> > work on all
    >> > versions of Excel so I have now used Late Binding instead of
    >> > referencing it.
    >> >
    >> > Unfortunately now I have done this I am getting debug errors
    >> > on:
    >> >
    >> > ppLayoutText
    >> > ppPasteMetafilePicture
    >> >
    >> > Can anyone help with a solution, please?
    >> >
    >> > Here is some of the code
    >> > *****************
    >> >
    >> > Dim pptApp As Object
    >> > Dim pptPres As Object
    >> > Dim pptSlide As Object
    >> > Dim pptShape As Object
    >> >
    >> > Set pptApp = CreateObject("PowerPoint.Application")
    >> > Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a
    >> > new
    >> > presentation
    >> > ' or open an existing presentation
    >> > ' Set pptPres =
    >> > pptApp.Presentations.Open("C:\Foldername\Filename.ppt")
    >> >
    >> > ' apply a slide template
    >> > pptPres.ApplyTemplate "C:\Program Files\Microsoft
    >> > Office\Templates\Presentation Designs\Contemporary
    >> > Portrait.pot"
    >> >
    >> >
    >> > For Each asheet In ActiveWorkbook.Sheets
    >> > ' only officer sheets visible at this point
    >> > If asheet.Visible = True Then
    >> > sheetname = asheet.Name
    >> > Worksheets(sheetname).Activate
    >> >
    >> > With ActiveSheet
    >> > .Shapes("Slide").Copy ' copy a picture from
    >> > Excel
    >> >
    >> > With pptPres.Slides
    >> > Set pptSlide = .Add(.Count + 1, ppLayoutText)
    >> > '
    >> > add a slide
    >> > End With
    >> >
    >> > With pptSlide
    >> >
    >> > .Shapes(1).Delete ' remove title
    >> > '.Shapes(2).Delete ' remove the text box
    >> > .Shapes.PasteSpecial ppPasteMetafilePicture
    >> >
    >> > With .Shapes(.Shapes.Count)
    >> > .Left = 0
    >> > .Top = 0
    >> > .Width = 720
    >> > .Height = 540
    >> > End With
    >> > End With
    >> > End With
    >> > End If
    >> > Next asheet
    >> >
    >> > etc.....
    >> >

    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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