Send image of an xl page to powerpoint

R1

New Member
Joined
Aug 16, 2004
Messages
24
Hi,
I wrote this code to send from my current page in xls the content into a new ppt presentation.
I have 2 pbm I can't resolve:
1) the created image is ok when the code runs on my laptop. But when it runs on a PC (with probably a different screen definition), the right side of the image disapear.
2) I would like the macro to add the charts to the same presentation. But it creats each time I launch it a new ppt presentation.

Anyone can help?
Thank you
-------------------------------------------------
Sub MoveActiveChartToPPT()

' Dim strMsg As String
Dim appPPT As New PowerPoint.Application
Dim pptActive As PowerPoint.Presentation
Dim slideNew As Slide
Dim Title
Dim Comment
Dim strcomment
Dim shpcomment
Dim strtitle
Dim slidecount As Integer
Dim shpChart As PowerPoint.Shape, shpTitle As PowerPoint.Shape
' Dim i%

On Error GoTo GestionErreurs

Title = InputBox("Please enter a Title:")
Comment = InputBox("Please enter a Comment:")


With appPPT
.Visible = True
Set pptActive = .Presentations.Add
.Activate

slidecount = pptActive.Slides.Count
Set slideNew = pptActive.Slides.Add(slidecount + 1, ppLayoutBlank)
appPPT.ActiveWindow.View.GotoSlide slideNew.SlideIndex

End With


With pptActive

.Slides(1).Shapes.AddLabel(Orientation:=msoTextOrientationHorizontal, _
Left:=40, Top:=30, Width:=60, Height:=100).TextFrame.TextRange.Text = Title

End With

With pptActive
Set shpTitle = slideNew.Shapes(1)
End With

strtitle = Title
With shpTitle
.Top = 10
.Left = pptActive.PageSetup.SlideWidth / 4
.Width = pptActive.PageSetup.SlideWidth - pptActive.PageSetup.SlideWidth / 4
With .TextFrame.TextRange
.Text = strtitle
.ParagraphFormat.Alignment = ppAlignLeft
With .Font
.NameAscii = "Arial"
.Size = 26
.Bold = msoTrue
.BaselineOffset = 0
.Color.SchemeColor = ppTitle
End With
End With
End With

With pptActive

.Slides(1).Shapes.AddLabel(Orientation:=msoTextOrientationHorizontal, _
Left:=40, Top:=60, Width:=60, Height:=300).TextFrame.TextRange.Text = Comment

End With
With pptActive
Set shpcomment = slideNew.Shapes(2)
End With

strcomment = Comment
With shpcomment
.Top = 45
.Left = 8
.Width = pptActive.PageSetup.SlideWidth - 8
With .TextFrame.TextRange
.Text = strcomment
.ParagraphFormat.Alignment = ppAlignLeft
With .Font
.NameAscii = "Arial"
.Size = 16
.Bold = msoTrue
.BaselineOffset = 0
.Color.RGB = RGB(12, 80, 255)
End With
End With
End With
Range("c1:aa44").Select

' Copy the range as a picture
Selection.CopyPicture Appearance:=xlScreen, _
Format:=xlPicture

' Paste the range
slideNew.Shapes.Paste.Select

' Align the pasted range
appPPT.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
appPPT.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True




Set shpChart = slideNew.Shapes(slideNew.Shapes.Count)
With shpChart
.Left = pptActive.PageSetup.SlideWidth * 0.03
.Top = 85
.Width = pptActive.PageSetup.SlideWidth * 0.95
End With


' Clean up
Set slideNew = Nothing
Set appPPT = Nothing
Set pptActive = Nothing

Range("a1").Select
Exit Sub

GestionErreurs:
Resume Next
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,144,376
Messages
5,724,001
Members
422,530
Latest member
Badpoisondwarf

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
Top