Powerpoint/Access 2007 Automation Issue

padlocked17

Registered User.
Local time
Today, 15:36
Joined
Aug 29, 2007
Messages
275
The following is some code I'm using to create a powerpoint from access data. I stripped away all non-esential code.

If you look in the comments on the second portion of code you see where Access 2007 isn't processing correctly. Tells me that value is out of range and give a long 10 digit number (not an error number that I know of)

Any ideas why this is occurring?

Code:
Sub makePowerPoint()
On Error GoTo err_cmdOLEPowerPoint
    
    Dim rs As DAO.Recordset
    Dim ppObj As PowerPoint.Application
    Dim ppPres As PowerPoint.Presentation
    Dim template1 As String
    Dim template2 As String
    Dim x As Integer
    
    ' Open up an instance of Powerpoint.
    Set ppObj = New PowerPoint.Application
    
    'Open PPT so you can watch process, comment out to just create & save file
    ppObj.Activate
    
    'create new powerpoint presentation
    Set ppPres = ppObj.Presentations.Add
    x = 1
    
    
    ' Setup the set of slides
    With ppPres

        'there are persons for this slide
            'create slide
            InsertSlide ppPres, x, "PP"

Code:
Sub InsertSlide(pres As PowerPoint.Presentation, index As Integer, slidetype As String)
    'inserts a new slide, adds needed objects and returns slide's index #
    Dim newShape As PowerPoint.Shape

    With pres
        .Slides.Add index, ppLayoutBlank
        With .Slides(index).Background.Fill
            .Visible = msoTrue
            .Solid
            .ForeColor.RGB = RGB(51, 204, 51)
            .Transparency = 0#
        End With

	'-------------------------
	'
	'Errors out here on the next line.
	'
	'-------------------------
        .Slides(index).Shapes.AddTextbox msoTextOrientationHorizontal, 10, 10, 700, 40
        With .Slides(index).Shapes(1)
            .TextFrame.TextRange.Text = "Title1"
            .TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
            .TextFrame.TextRange.Font.Size = 40
        End With
 
Why would the :

Code:
With pres
.Slides(index).Shapes.AddTextbox msoTextOrientationHorizontal, 10, 10, 700, 40

Line error out?
 
Turns out if I use the following syntax it works correctly:

Code:
.Slides(index).Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 10, 700, 40).Apply
 

Users who are viewing this thread

Back
Top Bottom