Consulting

Results 1 to 2 of 2

Thread: Special paste and formatting Word 2010

  1. #1

    Special paste and formatting Word 2010

    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

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try something along the lines of:
    [vba]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[/vba]
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •