Saturday, 8 June 2013

Pasting and re-sizing a screenshot

Pasting and re-sizing a screenshot

I often take screen shots of random drawings and i want to re-size them using a macro. I want the macro to automatically paste the screenshot then re-size it to fit to a height of 5.9 inches and a width of 10 inches. The current macro that I'm using works perfectly as long as the screenshot isn't to tall (in height) but i want it to adjust to the nearest width (10) or height (5.9) which ever one comes first. Any suggestions?
Kyle
Sub Resize()

  If ActiveDocument.Shapes.Count = 3 Then
    ActiveDocument.Shapes(3).Select
    Selection.shapeRange.Delete
  End If
  Application.ScreenUpdating = False
  Selection.Paste
  If ActiveDocument.InlineShapes.Count = 1 Then
    ActiveDocument.InlineShapes(1).ConvertToShape
  End If
  If ActiveDocument.Shapes.Count = 3 Then
    With ActiveDocument.Shapes(3)
      .WrapFormat.Type = wdWrapFront
      .LockAspectRatio = msoTrue
      .Height = InchesToPoints(5.9)
     ' .Width = InchesToPoints(10)

      .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
     .RelativeVerticalPosition = wdRelativeVerticalPositionPage
      .Top = InchesToPoints(0.8)
      .Left = wdShapeCenter
    End With
  End If
  Application.ScreenUpdating = True
End Sub

No comments:

Post a Comment