Solved Why am I getting a Type Mismatch Here? (1 Viewer)

prabha_friend

Prabhakaran Karuppaih
Local time
Tomorrow, 00:17
Joined
Mar 22, 2009
Messages
790
Sub mac()
Dim newPPTapp As New PowerPoint.Application
With newPPTapp
.Visible = msoTrue
With .Presentations.Add(msoTrue)
Call .Slides.AddSlide(1, ppLayoutBlank)
End With
End With
End Sub
 

Minty

AWF VIP
Local time
Today, 19:47
Joined
Jul 26, 2013
Messages
10,371
Which line of code giving you the error, and please indent and put your code in code tags.
Is this in Powerpoint?

Give us all a bit more of a clue.
 

prabha_friend

Prabhakaran Karuppaih
Local time
Tomorrow, 00:17
Joined
Mar 22, 2009
Messages
790
Which line of code giving you the error, and please indent and put your code in code tags.
Is this in Powerpoint?

Give us all a bit more of a clue.
Code:
Sub mac()
Dim newPPTapp As New PowerPoint.Application
With newPPTapp
    .Visible = msoTrue
    With .Presentations.Add(msoTrue)
        Call .Slides.AddSlide(1, ppLayoutBlank)
    End With
End With
End Sub

Getting "Type Mismatch" on "Slides.addslide(1,ppLayoutBlank)"
 

sonic8

AWF VIP
Local time
Today, 20:47
Joined
Oct 27, 2015
Messages
998
You are getting a type mismatch because AddSlides expects an object of type CustomLayout but you pass in an enum value (Long) of the PpSlideLayout enum.

Look at the documentation of AddSlides method for a working example.
 

prabha_friend

Prabhakaran Karuppaih
Local time
Tomorrow, 00:17
Joined
Mar 22, 2009
Messages
790
For creating second slides it's working but how to create the 1st slide. Please test the code posted in the link. It's not working for the very slide to create.

With Hope,
Prabhakaran
 

June7

AWF VIP
Local time
Today, 10:47
Joined
Mar 9, 2014
Messages
5,490
Here is example code from my db.
Code:
Sub cmdPowerPoint_Click()
    Dim db As Database, rs As Recordset, fd As Field2
    Dim ppObj As PowerPoint.Application
    Dim ppPres As PowerPoint.Presentation

    'On Error GoTo err_cmdOLEPowerPoint

    ' Open up a recordset on the Employees table.
    Set db = CurrentDb
    Set rs = db.OpenRecordset("SELECT * FROM Umpires WHERE ID = 1", dbOpenDynaset)
   
    ' Open up an instance of Powerpoint.
    Set ppObj = New PowerPoint.Application
    Set ppPres = ppObj.Presentations.Add

    ' Setup the set of slides and populate them with data from the
    ' set of records.
    With ppPres
        While Not rs.EOF
            With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTitle)
                .Shapes(1).TextFrame.TextRange.text = "Hi!  Page " & rs.AbsolutePosition + 1
                .SlideShowTransition.EntryEffect = ppEffectFade
                With .Shapes(2).TextFrame.TextRange
                    .text = rs("LastN")
                    .Characters.Font.Color.RGB = RGB(255, 0, 255)
                    .Characters.Font.Shadow = True
                End With
               
                With .Shapes.AddShape(msoShapeOval, 360, 121, 220, 220) 'photo
                    'Set fd = rs("Test1")
                    'fd("FileData").SaveToFile CurrentProject.Path
                    '.Fill.UserPicture CurrentProject.Path & "\" & fd("FileName")
                    '.line.Visible = False   'no outline
                    'Kill CurrentProject.Path & "\" & fd("FileName")
                End With
               
                With .Shapes.AddShape(msoShapeOval, 85, 260, 85, 85) 'customer
                     .Fill.ForeColor.RGB = RGB(239, 48, 120)
                     .line.Visible = False
                End With

                With .Shapes.AddShape(msoShapeOval, 85, 355, 135, 135) 'improvement (down)
                     .Fill.ForeColor.RGB = RGB(0, 176, 240)
                     .line.Visible = False
                End With

                With .Shapes.AddShape(msoShapeOval, 38, 136, 110, 110) 'staff
                     .Fill.ForeColor.RGB = RGB(238, 149, 36)
                     .line.Visible = False
                End With
   
                With .Shapes.AddShape(msoShapeOval, 158, 45, 135, 135) 'improvement (up)
                     .Fill.ForeColor.RGB = RGB(0, 176, 240)
                     .line.Visible = False
                End With

                With .Shapes.AddShape(msoShapeOval, 193, 206, 135, 135) 'characteristics
                     .Fill.ForeColor.RGB = RGB(238, 149, 36)
                     .line.Visible = False
                End With
               
                .Shapes(1).TextFrame.TextRange.Characters.Font.Size = 50
            End With
            rs.MoveNext
        Wend
    End With

    ' Run the show.
    ppPres.SlideShowSettings.Run

    Exit Sub

err_cmdOLEPowerPoint:
    MsgBox Err.Number & " " & Err.Description
End Sub
 

prabha_friend

Prabhakaran Karuppaih
Local time
Tomorrow, 00:17
Joined
Mar 22, 2009
Messages
790
Found out the cause. It's slides.add not slides.addslide
 

Users who are viewing this thread

Top Bottom