ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I refer to a freeform name and number on a chart using VBA (https://www.excelbanter.com/excel-programming/346236-how-do-i-refer-freeform-name-number-chart-using-vba.html)

Raas

How do I refer to a freeform name and number on a chart using VBA
 

--
Raas

Vic Eldridge[_3_]

How do I refer to a freeform name and number on a chart using VBA
 
ActiveChart.Shapes("Freeform 1").Fill.ForeColor.RGB = vbRed

"Raas" wrote:


--
Raas


Raas

How do I refer to a freeform name and number on a chart using
 
Thank you, but I already knew this part. I want to be able to retrieve the
freeform name and number from the system so I can refer to it. Each new
polygon I put on this chart gets a new freeform number assigned
automatically, and I need to retrieve this number out of the name.
--
Raas


"Vic Eldridge" wrote:

ActiveChart.Shapes("Freeform 1").Fill.ForeColor.RGB = vbRed

"Raas" wrote:


--
Raas


Vic Eldridge[_3_]

How do I refer to a freeform name and number on a chart using
 
Hi Raas,

When creating any object (such as a shape object) , you can assign the
object to an "object variable" , whose scope and lifetime are at your
complete control.

eg

Sub AddFreeformShape()

Dim FFB As FreeformBuilder
Dim Shp As Shape

Set FFB =
ActiveSheet.ChartObjects(1).Chart.Shapes.BuildFree form(msoEditingCorner, 360,
200)
With FFB
.AddNodes msoSegmentCurve, msoEditingCorner, 380, 230, 400, 250,
450, 300
.AddNodes msoSegmentCurve, msoEditingAuto, 480, 200
.AddNodes msoSegmentLine, msoEditingAuto, 480, 400
.AddNodes msoSegmentLine, msoEditingAuto, 360, 200
Set Shp = .ConvertToShape
End With

MsgBox Shp.Name

End Sub




"Raas" wrote:

Thank you, but I already knew this part. I want to be able to retrieve the
freeform name and number from the system so I can refer to it. Each new
polygon I put on this chart gets a new freeform number assigned
automatically, and I need to retrieve this number out of the name.
--
Raas


"Vic Eldridge" wrote:

ActiveChart.Shapes("Freeform 1").Fill.ForeColor.RGB = vbRed

"Raas" wrote:


--
Raas


Raas

How do I refer to a freeform name and number on a chart using
 
Thank you! That helped a lot. Good have you out there for learners like
myself.
--
Raas


"Vic Eldridge" wrote:

Hi Raas,

When creating any object (such as a shape object) , you can assign the
object to an "object variable" , whose scope and lifetime are at your
complete control.

eg

Sub AddFreeformShape()

Dim FFB As FreeformBuilder
Dim Shp As Shape

Set FFB =
ActiveSheet.ChartObjects(1).Chart.Shapes.BuildFree form(msoEditingCorner, 360,
200)
With FFB
.AddNodes msoSegmentCurve, msoEditingCorner, 380, 230, 400, 250,
450, 300
.AddNodes msoSegmentCurve, msoEditingAuto, 480, 200
.AddNodes msoSegmentLine, msoEditingAuto, 480, 400
.AddNodes msoSegmentLine, msoEditingAuto, 360, 200
Set Shp = .ConvertToShape
End With

MsgBox Shp.Name

End Sub




"Raas" wrote:

Thank you, but I already knew this part. I want to be able to retrieve the
freeform name and number from the system so I can refer to it. Each new
polygon I put on this chart gets a new freeform number assigned
automatically, and I need to retrieve this number out of the name.
--
Raas


"Vic Eldridge" wrote:

ActiveChart.Shapes("Freeform 1").Fill.ForeColor.RGB = vbRed

"Raas" wrote:


--
Raas



All times are GMT +1. The time now is 05:45 PM.

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