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>
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,691
Office Version
  1. 2010
Platform
  1. Windows
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:

ParamRay

Well-known Member
Joined
Aug 6, 2014
Messages
1,195
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
 

zgivod

New Member
Joined
Dec 6, 2018
Messages
17
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:

zgivod

New Member
Joined
Dec 6, 2018
Messages
17
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
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,691
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

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:

zgivod

New Member
Joined
Dec 6, 2018
Messages
17
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
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,691
Office Version
  1. 2010
Platform
  1. Windows
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
 

zgivod

New Member
Joined
Dec 6, 2018
Messages
17
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,832
Messages
5,598,358
Members
414,233
Latest member
WolverineNurse

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
Top