VBA excel to PowerPoint help

Dremzy

New Member
Joined
Apr 19, 2014
Messages
29
Hi guys,

I need a macro to copy and paste two images (picture 1 and picture 2) from excel to a new powerpoint slide AS WELL as the following range (F28:O44).

Ideally I would like the two pictures to be in the top left and right of the slide and then the range to be below that (in the powerpoint file).

Can anyone help??

I have found some codes to copy the full range including the pictures however it pastes it like one big image (including gridlines) which is not ideal
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi

See if this helps. What Office version are you using?

pp1.JPG


Code:
' at Excel module
Sub Dremzy()
Dim pres As PowerPoint.Presentation, oppapp As Object, sl As PowerPoint.Slide
On Error Resume Next
Set oppapp = GetObject(, "PowerPoint.Application")
If Err.Number <> 0 Then Set oppapp = CreateObject("PowerPoint.Application")
Err.Clear
On Error GoTo 0
oppapp.Visible = True
Set pres = oppapp.Presentations.Add
Set sl = pres.Slides.Add(1, ppLayoutBlank)
ActiveSheet.Pictures("Image2").Copy
oppapp.ActiveWindow.View.PasteSpecial ppPasteDefault
sl.Shapes(1).Top = 0
sl.Shapes(1).Left = 0
sl.Shapes(1).Height = pres.PageSetup.SlideHeight / 2
ActiveSheet.Pictures("Image3").Copy
oppapp.ActiveWindow.View.PasteSpecial ppPasteDefault
sl.Shapes(2).Top = 0
sl.Shapes(2).LockAspectRatio = msoTrue
sl.Shapes(2).Height = pres.Slides(1).Shapes(1).Height
sl.Shapes(2).Left = pres.PageSetup.SlideWidth - pres.Slides(1).Shapes(2).Width
ActiveSheet.Range("f28:o44").CopyPicture xlScreen, xlBitmap
oppapp.ActiveWindow.View.PasteSpecial ppPasteDefault
sl.Shapes(3).LockAspectRatio = msoTrue
sl.Shapes(3).Height = pres.PageSetup.SlideHeight / 2
sl.Shapes(3).Top = pres.PageSetup.SlideHeight / 2
sl.Shapes(3).Left = (pres.PageSetup.SlideWidth - pres.Slides(1).Shapes(3).Width) / 2
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,619
Members
449,039
Latest member
Mbone Mathonsi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top