Saqib Husain
asked on
Drawig Freeform shapes using VBA
I created a Freeform shape while recording a macro. When I try to use that macro I often run into an error depending on the values used.
In the code below I have two parts. The first is the lines recorded and it works fine. The second part is with my values but it gives an error.
Can someone explain the error and propose a remedy?
Saqib
Sub Fform()
With ActiveSheet.Shapes.BuildFr eeform(mso EditingAut o, 4804.5, 117932.25)
.AddNodes msoSegmentLine, msoEditingAuto, 4742.25, 117978#
.AddNodes msoSegmentLine, msoEditingAuto, 4747.5, 118057.5
.AddNodes msoSegmentLine, msoEditingAuto, 4904.25, 118102.5
.AddNodes msoSegmentLine, msoEditingAuto, 4956.75, 118044#
.ConvertToShape.Select
End With
With ActiveSheet.Shapes.BuildFr eeform(mso EditingAut o, 6979.297118, 7097.833484)
.AddNodes msoSegmentLine, msoEditingAuto, 6980.243934, 7097.982595
.AddNodes msoSegmentLine, msoEditingAuto, 6979.947016, 7095.819007
.ConvertToShape.Select
End With
End Sub
In the code below I have two parts. The first is the lines recorded and it works fine. The second part is with my values but it gives an error.
Can someone explain the error and propose a remedy?
Saqib
Sub Fform()
With ActiveSheet.Shapes.BuildFr
.AddNodes msoSegmentLine, msoEditingAuto, 4742.25, 117978#
.AddNodes msoSegmentLine, msoEditingAuto, 4747.5, 118057.5
.AddNodes msoSegmentLine, msoEditingAuto, 4904.25, 118102.5
.AddNodes msoSegmentLine, msoEditingAuto, 4956.75, 118044#
.ConvertToShape.Select
End With
With ActiveSheet.Shapes.BuildFr
.AddNodes msoSegmentLine, msoEditingAuto, 6980.243934, 7097.982595
.AddNodes msoSegmentLine, msoEditingAuto, 6979.947016, 7095.819007
.ConvertToShape.Select
End With
End Sub
Nope. I was wrong. The problem is you are using values with too many decimal positions. Cut them down to two decimals or no decimals and you will have better luck.
Kevin
Kevin
ASKER
I dont think so, Kevin.
Try this
With ActiveSheet.Shapes.BuildFr eeform(mso EditingAut o, 6979.297118, 7097.833484)
.AddNodes msoSegmentLine, msoEditingAuto, 7980.243934, 7097.982595
.AddNodes msoSegmentLine, msoEditingAuto, 7979.947016, 7095.819007
.ConvertToShape.Select
End With
Try this
With ActiveSheet.Shapes.BuildFr
.AddNodes msoSegmentLine, msoEditingAuto, 7980.243934, 7097.982595
.AddNodes msoSegmentLine, msoEditingAuto, 7979.947016, 7095.819007
.ConvertToShape.Select
End With
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ssagibh:
I agree with Kevin. I played with it a bit and when I moved the nodes farther apart it worked fine.
Jaes
I agree with Kevin. I played with it a bit and when I moved the nodes farther apart it worked fine.
Jaes
Kevin