![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]() Don't see why that doesn't work but I think I would do it like this: Code:
Sub TestCode() Dim objPPTApp As Object Dim objPPPres As Object Dim objPPSld As Object 'Open Existing PowerPoint Set objPPTApp = CreateObject("PowerPoint.Application") With objPPTApp .Visible = True Set objPPPres = .Presentations.Open("C:\Users\John\Documents\Test\Test.pptx") End With Set objPPSld = objPPPres.Slides(1) Call addpic(objPPPres, objPPSld, "C:\Users\John\Documents\test\Pic1.jpg") Call addpic(objPPPres, objPPSld, "C:\Users\John\Documents\test\Pic2.jpg") End Sub Sub addpic(opres As Presentation, osld As Slide, strPath As String) Dim opic As Shape Set opic = osld.Shapes.AddPicture(strPath, False, True, 1, 1, -1, -1) With opic .LockAspectRatio = True .Width = 500 With opres.PageSetup opic.Left = (.SlideWidth \ 2) - (opic.Width \ 2) opic.Top = (.SlideHeight \ 2) - (opic.Height \ 2) End With End With End Sub |
#2
|
|||
|
|||
![]()
Hello JohnWilson again, thank your for your continued help, I really appreciate it. I ran the code you offered and am getting a type mismatch error on the line containing .addPicture. Even with this error the picture is inserted into slide 1 but then it stops. I can't figure out what is causing the mismatch, objPPTAAppa is the PowerPoint Application object, objPPPres is the specific PowerPoint file, looks like objPPSid is the ID of slide 1, that all makes sense to me, not sure what is causing the mismatch.
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Jamal NUMAN | Outlook | 3 | 04-20-2011 06:32 PM |
Duration changes fail to update work effort | Panteledes | Project | 6 | 05-25-2010 02:27 PM |
Secondary IP address Outlook Fail-over | danish.mustafa | Outlook | 0 | 03-01-2010 01:32 AM |
Help with forms (shifting focus) | jrh312 | Word | 0 | 11-19-2009 12:59 PM |
Shortcuts Fail | sussertown | Outlook | 0 | 02-16-2009 06:38 PM |