Excel To Powrpoint Text

stickerman

New Member
Joined
Jan 15, 2013
Messages
5
Hi. I am a comparatively novice programmer and have recently come across the ability to create a Powerpoint direct from VBA in Excel. Most of what I want to do is working, with the following exception.
If I manually copy some text from Excel and paste them to an open powerpoint, I have 5 options for posting. The first two offer what I want: to keep the text size etc and be able to later it in Powerpoint - particularly I want to add a drop shadow. However, when I do this using VBA I can obviously copy and paste, but the resulting image doesn't allow me to access / alter the text. The programming lines I have involved are:
Dim r, s, SheetNo, SheetPosition
Dim rng As Range
Dim PowerPointApp As Object
Dim myPresentation As Object
Dim mySlide As Object
Dim myShape As Object

Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
'Create a New Presentation
Set myPresentation = PowerPointApp.Presentations.Add
myPresentation.PageSetup.SlideSize = 1

'Add a slide to the Presentation
Set mySlide = myPresentation.Slides.Add(SheetNo, 12)
'Copy Excel Range
Set rng = ThisWorkbook.Worksheets("Slide 2").Range("a21:i41")
rng.Copy

'Paste to PowerPoint and position
mySlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
Set myShape = mySlide.Shapes(mySlide.Shapes.Count)

Can anyone tell me what I need to do to change this? I would guess the answer is somewhere in the "mySlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile" sctions, but I'm out of my depth here.
Thanks for any help
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
In order to be able to alter the pasted text as well as to add shadows replace those two lines of code
VBA Code:
'Paste to PowerPoint and position
mySlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
Set myShape = mySlide.Shapes(mySlide.Shapes.Count)


either with this
VBA Code:
Set myShape = mySlide.Shapes.PasteSpecial(DataType:=8)     '8 = ppPasteHTML
Application.CutCopyMode = False

or with this
VBA Code:
Set myShape = mySlide.Shapes.PasteSpecial(DataType:=10)     '10 = ppPasteOLEObject
Application.CutCopyMode = False
 
Upvote 0
Thanks for the quick reply - limited success
The two line options you gave me are dfferent by the reference number at the end. The results I get are:
8: this works as far as altering the text is concerned, but the text copied over is reduced in size. Example, a line of 32point text comes on the PP at 20 point.
Is there something else I need to do?
 
Upvote 0
... the text copied over is reduced in size. Example, a line of 32point text comes on the PP at 20 point.
Is there something else I need to do?
I've tested it in Office 2013. After pasting in PP as HTML the text formatting (color, size, etc) is maintained and the formatting of the resulting shape can be changed, but only partly (fill, shadow, reflection, size, position & text box).
 
Upvote 0
I've tested it in Office 2013. After pasting in PP as HTML the text formatting (color, size, etc) is maintained and the formatting of the resulting shape can be changed, but only partly (fill, shadow, reflection, size, position & text box).
Hello and thank you for your reply.
Sadly, I have also had another go, using HTML, but although the text style stays the same, the size still defaults from 32 to 18point! I wonder if it it's because I'm using Office 365?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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