View Single Post
 
Old 09-22-2021, 06:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,978
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I would do it with a sub and a function. This is a bit fuller featured in that you can type in things more things than the basic 1, 2, 3, or 4. For instance, try 0.5 or -0.5. Note that if you run this code on pictures more than once it reveals that each rotation is always relative to the ORIGINAL graphic orientation so you could put 0 into the dialog to set the graphic(s) back to the original orientation.
Code:
Sub RotateOnIt()
  Dim inShp As InlineShape, aRng As Range, iResp As Double, iResp2 As Double, sMsg As String, sMsg2 As String
  
  sMsg = "Selected Picture(s):" & vbCr & "  Type 1 for 90 degrees" & vbCr & "  Type 2 for 180 degrees" & vbCr & "  Type 3 for -90 degrees"
  sMsg2 = sMsg & vbCr & vbCr & "Ask me each time:" & vbCr & "  Type 4"
  Set aRng = Selection.Range
          
  If aRng.InlineShapes.Count = 1 Then
    iResp = InputBox(sMsg, "Make a Selection", "1")
  ElseIf aRng.InlineShapes.Count > 1 Then
    iResp = InputBox(sMsg2, "Make a Selection", "1")
  Else
    MsgBox "You must select inline shapes first.", vbExclamation + vbOKOnly, "Almost..."
    Exit Sub
  End If

  For Each inShp In aRng.InlineShapes
    If inShp.Type = wdInlineShapePicture Then
      Select Case iResp
        Case Is < 4
          PicRotate inShp, iResp
        Case 4
          inShp.Range.Select
          iResp2 = InputBox(sMsg, "Make a Selection", "1")
          PicRotate inShp, iResp2
      End Select
    End If
  Next
End Sub

Function PicRotate(inShp As InlineShape, iRot As Double)
  Dim Shp As Shape
  Set Shp = inShp.ConvertToShape
  Shp.Rotation = iRot * 90
  Shp.ConvertToInlineShape
End Function
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote