Name a BuildFreeform shape Question

julhs

Active Member
Joined
Dec 3, 2018
Messages
407
Office Version
  1. 2010
Platform
  1. Windows
The code below constructs a Freeform shape, how can I give the shape a meaning full/given name so that it is not simply given “Freeform ??? what ever” when it gets converted to a shape.

VBA Code:
Sub DrawFreeformME()
Dim ws As Worksheet, fb As FreeFormBuilder
Set ws = ActiveSheet
' Create freeform
Set fb = ws.Shapes.BuildFreeform(msoEditingAuto, 380, 230)
' Add segments.
fb.AddNodes msoSegmentCurve, msoEditingCorner, _
380, 230, 400, 250, 450, 300
fb.AddNodes msoSegmentCurve, msoEditingAuto, 480, 200
fb.AddNodes msoSegmentLine, msoEditingAuto, 480, 400
fb.AddNodes msoSegmentLine, msoEditingAuto, 380, 230
' Render drawing.
fb.ConvertToShape
End Sub
 
You two are talking about detail way over my head!!! (that’s not a surprise)
However; I’m trying to follow it and learn what I can.
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
HI
Our discussion, very interesting for me, is a question of "goat's wool" (lana caprina) as they say in Italy.
As I said Micron's solution is much more streamlined than mine. It is better if you follow his suggestions.
Hi,
Mario
 
Upvote 0
Think of it like parents and children. Forgetting anything to do with the application itself, think of the workbook as the parent object.
One wb (grandpa) can have many sheets (children). The sheets belong to a group/family called a collection, which is an object itself. Sometimes there can only be one collection of any type (such as only one collection of sheets). So if parent (wb) contains sheet1, sheet2 and sheet3 then there are 3 sheets in the one sheets collection that belongs to the workbook (grandpa).

A sheet can also be a parent and have its own collections of differing types. Shapes is one of them. Each sheet can have its own collection of shapes because the shapes collection belongs to (is a child of) the sheet, not the workbook. To get at a particular shape contained in the collection object requires that we refer to the index of the collection. The index property will accept a number (e.g. 1) or the name of the shape in order to identify which shape in the collection you want to refer to. However you cannot start there. You must start the reference in a top down fashion (like an org chart). Where you must start depends on certain factors but let's look at it like the following just as an example.

So I've been saying that even references like the one offered - ActiveSheet.Shapes("YourName").Select

is still invoking the shapes collection (my grandpa is not referenced here but I can do so in a second example):
GrandpaDadChildIndex (name or number)Action (Method)
ActiveSheet.Shapes("YourName").Select
Thisworkbook.ActiveSheet.Shapes("YourName").Select

Much of the time you can think of a lower member of the real hierarchy to be the topmost level if you wish because sometimes upper levels are assumed by default. ThisWorkbook is one of those that need not be used in the reference in this case.
HTH explain some of it. Might be worthwhile to research vba collections, and if you're really into this stuff, dictionaries (somewhat like a collection object).
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

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
Back
Top