PDA

View Full Version : Special paste and formatting Word 2010



losttruths
07-16-2012, 03:48 AM
I have been having some real trouble with this and i know its probably very simple. I haven't used VBA since college(not that i was ever very good). I code it to special paste and the formatting, but I cant code it into one. If you could show me where i'm going wrong i would be really grateful!

program version: 2010

I want to try and streamline putting slides from powerpoint(2010) into a word document. I copy the desired slide and special paste it into word then need to change it to 60% of its original height and width format it to square and align it to the centre.


formatting macro
Sub allbutpaste()


Dim PecentSize As Integer

PercentSize = 60

If Selection.InlineShapes.Count > 0 Then
Selection.InlineShapes(1).ScaleHeight = PercentSize
Selection.InlineShapes(1).ScaleWidth = PercentSize
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Set t = Selection.InlineShapes(1).ConvertToShape
t.WrapFormat.Type = wdWrapSquare
Else
Selection.ShapeRange.ScaleHeight Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
Selection.ShapeRange.ScaleWidth Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Set t = Selection.InlineShapes(1).ConvertToShape
t.WrapFormat.Type = wdWrapSquare
End If
End Sub

Paste macro
Sub pasteSPEC()
'
' test1 Macro
'
'
Selection.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, Placement _
:=wdInLine, DisplayAsIcon:=False

End Sub

Sure there is a better way of doing it! Thanks in advance!

Leo

macropod
07-17-2012, 02:13 AM
Try something along the lines of:
Sub pasteSPEC()
Const PercentSize As Integer = 60
Selection.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
With Selection.ShapeRange
.LockAspectRatio = True
.ScaleWidth PercentSize / 100, True
.ScaleHeight PercentSize / 100, False
End With
End Sub