Creating Shape at runtime

  • Thread starter Thread starter CG Rosén
  • Start date Start date
C

CG Rosén

Good Evening,

Any suggestions how to "clean" below code? My code is working as intented
but looks "amateurish".

Brgds

CG Rosén


Range("A1").Select
ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, "Filed", "Sylfaen", 36#, _
msoFalse, msoFalse, 329.25, 188.25).Select
Selection.ShapeRange.ScaleWidth 1.65, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.98, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.IncrementRotation -26.33
Selection.ShapeRange.IncrementLeft -164.25
Selection.ShapeRange.IncrementTop 40.5
 
I would use something like the following:

With ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, _
"Filed", _
"Sylfaen", _
36#, _
msoFalse, _
msoFalse, _
Range("D20").Left, _
Range("D20").Top)
.ScaleWidth 1.65, msoFalse, msoScaleFromTopLeft
.ScaleHeight 0.98, msoFalse, msoScaleFromBottomRight
.IncrementRotation -26.33
.IncrementLeft 0
.IncrementTop 0
End With

The top left of the original text is aligned with the D20 cell, which you can change to suit your spreadsheet layout and which will
probably allow you to eliminate the IncrementLeft and IncrementTop lines.I have left them in if you want to add fine adjustments.

The ScaleHeight line could also be eliminated if you are not too picky. It is only adjusting the height to 98% of its original
height.
 
Hi John,

Thanks for your answer!

Brgds

CG Rosén


John Green said:
I would use something like the following:

With ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, _
"Filed", _
"Sylfaen", _
36#, _
msoFalse, _
msoFalse, _
Range("D20").Left, _
Range("D20").Top)
.ScaleWidth 1.65, msoFalse, msoScaleFromTopLeft
.ScaleHeight 0.98, msoFalse, msoScaleFromBottomRight
.IncrementRotation -26.33
.IncrementLeft 0
.IncrementTop 0
End With

The top left of the original text is aligned with the D20 cell, which you
can change to suit your spreadsheet layout and which will
probably allow you to eliminate the IncrementLeft and IncrementTop lines.I
have left them in if you want to add fine adjustments.
The ScaleHeight line could also be eliminated if you are not too picky. It
is only adjusting the height to 98% of its original
 
Back
Top