Programmatically interact with PowerPoint

  • Thread starter Bill Sturdevant
  • Start date
B

Bill Sturdevant

I have an Access 2003 App that I have converted to Access 2007 -- a dictated
migration I am stuck with.

The app interacts programmatically with PowerPoint. The code below, which
copies a graph object in Access and pastes it into a PPT Presentation slide,
worked fine with Access 2003 and PowerPoint 2003. But, it fails in 2007.
The instruction:
pptSlide.Shapes.Paste
gets error:
Method 'Paste' of object 'Shapes' failed

It has been suggested that my code will not work because charting in PPT is
based on Excel and not on MS Graph. But, since I can stop the code
immediately after the "copy", then go to a PPT presentation and paste the
graph successfully, its seems I should be able to do so programmatically.

What do I need to change to get this working again?

--
Bill

Here is the code:
g_Four_R_GraphObj.ChartArea.Copy
With pptApp
With pptPresentation
If .Slides.count = 0 Then
Set pptSlide = .Slides.Add(1, ppLayoutTitleOnly)
Else
lngCurrentSlideIndex =
pptApp.ActiveWindow.View.Slide.SlideIndex + 1
Set pptSlide = .Slides.Add(lngCurrentSlideIndex,
ppLayoutTitleOnly)
End If

sText = Me.Chart_Title
pptSlide.Shapes.Title.TextFrame _
.TextRange.Text = sText
pptSlide.Shapes.Title.TextFrame.TextRange.Font.Size = 28
pptSlide.Shapes.Title.TextFrame.TextRange.Font.Bold = msoTrue

pptSlide.Shapes.Paste
With pptSlide.Shapes(pptSlide.Shapes.count)
.Left = 42
.Top = 114
.Width = 637
.Height = 377
End With

sText = Parent.Quadrant_Counts
pptSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, 42,
486, 637, 15).TextFrame _
.TextRange.Text = sText
pptSlide.Shapes(pptSlide.Shapes.count).TextFrame _
.TextRange.Font.Size = 12
pptSlide.Shapes(pptSlide.Shapes.count).TextFrame _
.TextRange.Font.Bold = msoTrue
pptSlide.Shapes(pptSlide.Shapes.count).TextFrame _
.TextRange.ParagraphFormat.Alignment =
ppAlignCenter

End With
End With
 
S

Stefan Hoffmann

hi Bill,

Bill said:
The app interacts programmatically with PowerPoint. The code below, which
copies a graph object in Access and pastes it into a PPT Presentation slide,
worked fine with Access 2003 and PowerPoint 2003. But, it fails in 2007.
The instruction:
pptSlide.Shapes.Paste
Hmm, I've always used

..ActivePresentation.Slides(SlideNumber).Shapes.PasteSpecial(ppPasteMetafilePicture)

Maybe that works for you.


mfG
--> stefan <--
 
B

Bill Sturdevant

Stefan,

I have tried every datatype listed in the MSDN documentatin for PasteSpecial
(ppPasteBitmap, ppPasteDefault, ppPasteEnhancedMetafile, ppPasteHTML,
ppPasteGIF, ppPasteJPG, ppPasteMetafilePicture, ppPastePNG, ppPasteShape )
and they all fail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top