ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2007 and vb... ShapeRange.ScaleWidth problems (https://www.excelbanter.com/excel-programming/399160-excel-2007-vbulletin-shaperange-scalewidth-problems.html)

Ken

Excel 2007 and vb... ShapeRange.ScaleWidth problems
 
I have a vb macro that automatically places several jpg image on a worksheet
and rescales then to fit in boxes on the page. This macro has worked well
until we upgraded to 2007. Does anyone know if there has been a change in
syntax.

Here is the current vb code:

Sub InsertPICS(PicPath As String, PicWidth As Integer, PicTop As Integer,
PicLeft As Integer)

Dim ScaleRatio As Single

ActiveSheet.Pictures.Insert(PicPath).Select
Selection.Name = "3DPic"
ScaleRatio = PicWidth / Selection.Width

With Selection

.ShapeRange.ScaleWidth ScaleRatio, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight ScaleRatio, msoFalse, msoScaleFromTopLeft
.Left = PicLeft
.Top = PicTop


End With

End Sub


Jon Peltier

Excel 2007 and vb... ShapeRange.ScaleWidth problems
 
Could you use the Height and Width properties? I prefer them anyway, and
maybe they don't experience the same problem.

Also, you say the code has worked well until now. Do you now get an error,
or does the size just come out wrong?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Ken" wrote in message
...
I have a vb macro that automatically places several jpg image on a
worksheet
and rescales then to fit in boxes on the page. This macro has worked well
until we upgraded to 2007. Does anyone know if there has been a change in
syntax.

Here is the current vb code:

Sub InsertPICS(PicPath As String, PicWidth As Integer, PicTop As Integer,
PicLeft As Integer)

Dim ScaleRatio As Single

ActiveSheet.Pictures.Insert(PicPath).Select
Selection.Name = "3DPic"
ScaleRatio = PicWidth / Selection.Width

With Selection

.ShapeRange.ScaleWidth ScaleRatio, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight ScaleRatio, msoFalse, msoScaleFromTopLeft
.Left = PicLeft
.Top = PicTop


End With

End Sub





All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com