rotate picture VBA

zgivod

New Member
Joined
Dec 6, 2018
Messages
17
am trying to upload a picture and then rotate it and move it to specific location but i cant seem to get it to rotate. i have this code bec. i want to save with document the picture


<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub tyh()

ActiveSheet
.Shapes.AddPicture _
Filename
:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
linktofile
:=msoFalse, savewithdocument:=msoCTrue, _
Left
:=1200, Top:=0, Width:=350, Height:=604
EndSub</code>
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
am trying to upload a picture and then rotate it and move it to specific location but i cant seem to get it to rotate. i have this code bec. i want to save with document the picture


<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub tyh()

ActiveSheet
.Shapes.AddPicture _
Filename
:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
linktofile
:=msoFalse, savewithdocument:=msoCTrue, _
Left
:=1200, Top:=0, Width:=350, Height:=604
EndSub</code>
Add this line of code immediately after the AddPicture line of code above...

ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90

where you would put the number of degrees counterclockwise that you wanted to rotate the picture in place of my example 90 degree number. Alternately, as the rotation will affect the placement for a non-square picture, you can omit the placement part of your original code, rotate the placed picture, then set the top and left properties after the rotation.
 
Last edited:
Upvote 0
Code:
  ActiveSheet.Shapes.AddPicture( _
    Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
    LinkToFile:=msoFalse, savewithdocument:=msoCTrue, _
    Left:=1200, Top:=0, Width:=350, Height:=604 _
  ).Rotation = 180
 
Upvote 0
Add this line of code immediately after the AddPicture line of code above...

ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90

where you would put the number of degrees counterclockwise that you wanted to rotate the picture in place of my example 90 degree number. Alternately, as the rotation will affect the placement for a non-square picture, you can omit the placement part of your original code, rotate the placed picture, then set the top and left properties after the rotation.


@Rick Rothstein can you please show me a example code i tried pasting that line of code but getting error. Thanks
 
Last edited:
Upvote 0
Code:
  ActiveSheet.Shapes.AddPicture( _
    Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
    LinkToFile:=msoFalse, savewithdocument:=msoCTrue, _
    Left:=1200, Top:=0, Width:=350, Height:=604 _
  ).Rotation = 180
@paramaRay your answer is blank
 
Upvote 0
can you please show me a example code i tried pasting that line of code but getting error. Thanks
Show me the whole code you used that produced the error and indicate on what line the error occurred.
 
Last edited:
Upvote 0
Show me the whole code you used that produced the error and indicate on what line the error occurred.

Code:
Sub oct2019ad()


ActiveSheet.Shapes.AddPicture _
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90 _
Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
linktofile:=msoFalse, savewithdocument:=msoCTrue, _
Left:=1200, Top:=0, Width:=350, Height:=604
End Sub

SYNTAX ERROR



Code:
Sub oct2019ad()


ActiveSheet.Shapes.AddPicture _
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90, _
Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
linktofile:=msoFalse, savewithdocument:=msoCTrue, _
Left:=1200, Top:=0, Width:=350, Height:=604
End Sub
RUN TIME ERROR 450';
WRONG NUMBER OF ARGUMENTS OR INVALID PROPERTY ASSIGNMENTS
 
Upvote 0
Code:
Sub oct2019ad()


ActiveSheet.Shapes.AddPicture _
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90 _
Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
linktofile:=msoFalse, savewithdocument:=msoCTrue, _
Left:=1200, Top:=0, Width:=350, Height:=604
End Sub

SYNTAX ERROR

Code:
Sub oct2019ad()
ActiveSheet.Shapes.AddPicture _
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90, _
Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
linktofile:=msoFalse, savewithdocument:=msoCTrue, _
Left:=1200, Top:=0, Width:=350, Height:=604
End Sub
RUN TIME ERROR 450';
WRONG NUMBER OF ARGUMENTS OR INVALID PROPERTY ASSIGNMENTS
You misinterpreted what I meant by "immediately after the AddPicture line of code"... those line continuation you have are all part of the same line of code. Specifically, this is an entire line of code...
Code:
  ActiveSheet.Shapes.AddPicture( _
    Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
    LinkToFile:=msoFalse, savewithdocument:=msoCTrue, _
    Left:=1200, Top:=0, Width:=350, Height:=604 _
  ).Rotation = 180
If was immediately after that that you were supposed to put the code I posted.
Code:
  ActiveSheet.Shapes.AddPicture( _
    Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
    LinkToFile:=msoFalse, savewithdocument:=msoCTrue, _
    Left:=1200, Top:=0, Width:=350, Height:=604 _
  ).Rotation = 180
  ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90
 
Upvote 0
You misinterpreted what I meant by "immediately after the AddPicture line of code"... those line continuation you have are all part of the same line of code. Specifically, this is an entire line of code...
Code:
  ActiveSheet.Shapes.AddPicture( _
    Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
    LinkToFile:=msoFalse, savewithdocument:=msoCTrue, _
    Left:=1200, Top:=0, Width:=350, Height:=604 _
  ).Rotation = 180
If was immediately after that that you were supposed to put the code I posted.
Code:
  ActiveSheet.Shapes.AddPicture( _
    Filename:="C:\Users\dovi.dovi-PC\Desktop\ads bh\IMG-7042.jpg", _
    LinkToFile:=msoFalse, savewithdocument:=msoCTrue, _
    Left:=1200, Top:=0, Width:=350, Height:=604 _
  ).Rotation = 180
  ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Rotation = 90
That works great thanks allot, my mistake
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top