PDA

View Full Version : How to paste & then resize an image



werafa
09-26-2012, 11:26 PM
hi, I Have borrowed one of John's magic modules to resize a shape, and tried to marry it with a paste command - end result is paste as enhanced metafile, then set position and size <not> :think:

I need to activate the shape to make it work under the current approach. How can I reliably identify it? or is there a better way?


Sub PasteTable()
Dim myShape As Object
'paste excel table as enhanced metafile, then resize to full width
ActiveWindow.Selection.SlideRange(1).Shapes.PasteSpecial ppPasteEnhancedMetafile
Set myShape = ActiveWindow.Selection 'for debugging
With ActiveWindow.Selection.ShapeRange(1)
.LockAspectRatio = True
.Top = 70 'points from top
.Left = 10 'points from left
.Width = 700 'points wide
End With
End Sub


Thanks all.

Cosmo
09-27-2012, 06:00 AM
The returned value of PasteSpecial is the shaperange which is pasted, so you can use that directly:

Sub PasteTable()
Dim myShape As Object
'paste excel table as enhanced metafile, then resize to full width
Set myShape = ActiveWindow.Selection.SlideRange(1).Shapes.PasteSpecial(ppPasteEnhancedMet afile)
With myShape
.LockAspectRatio = True
.Top = 70 'points from top
.Left = 10 'points from left
.Width = 700 'points wide
End With
End Sub

werafa
09-27-2012, 03:21 PM
So simple when you know how.
Thanks

and to anyone else reading this: there are links elsewhere in this forum to instructions for making custom ribbon buttons to run subs like this

Thanks to everyone who has helped me thus far
Tim

werafa
10-01-2012, 06:28 PM
Set myShape = ActiveWindow.Selection.SlideRange(1).Shapes.PasteSpecial(ppPasteEnhancedMet afile)

is giving me a " Shapes (unknown member) : invalid request. The specified data type is unavailable." error

I am using ppt 2007, and am not sure what I have missed. ideas?

Thanks

John Wilson
10-01-2012, 11:53 PM
There's a space that shouldn't be there in "ppPasteEnhancedMet afile". If that's really there that will be the problem. If not are you sure whatever you have in the clipboard can be pasted as an EMF. Try manually paste special and see if it's an option.

werafa
10-02-2012, 03:03 PM
John, The space is only in the VBAX post. Retyping in lowercase is picked up and capitalised correctly.

what is worse is that the @#$ thing has just decided to work and I can't make it play up in order to debug it. I think I will take a couple of aspirin and have a little nanna nap -- the previous comment about how wonderful you guys are stands.....

John Wilson
10-03-2012, 12:28 AM
Good it's working.

You might want to know that ppPasteEnhancedMetafile will only be recognised as a constant while PowerPoint is the active application. Hard to see how it wouldn't be but it enumerates to 2 so you can use that.


Sub PasteTable()
Dim myShape As Object
'paste excel table as enhanced metafile, then resize to full width
Set myShape = ActiveWindow.Selection.SlideRange(1).Shapes.PasteSpecial(DataType:=2)
With myShape
.LockAspectRatio = True
.Top = 70 'points from top
.Left = 10 'points from left
.Width = 700 'points wide
End With
End Sub

arronlee
08-26-2015, 08:58 PM
I wonder do I need any other image processors for help?

werafa
09-15-2015, 04:19 PM
what do you mean by this, and what do you wish to achieve?

this pastes an exzcel range as an image - and works with the normally available paste-special options for this task.
are you looking for something non-standard?