View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
DM Unseen DM Unseen is offline
external usenet poster
 
Posts: 233
Default Editing text in text box grouped within a trapezoid

Peter,

My code does not "ungroup" it just changes part of a shape-group(albeit
a *control* textbox and not a "shape" tetxbox)

After your comment I checked some more on the "Drawing textbox" and can
confirm that:

grouping drawing shapes, including the "drawing" textbox makes the
"characters" object in VBA (and indeed the text itsself) *unavailable*.
Ungrouped items do not have this issue(this is what you said).

Endusres can still edit the text though of the individual items

This anomaly comes with the following observation:

- When editing (text) in shapegroups in excel; , excel goes into "Text
Edit Mode", in this mode you can change the text of the shape(s). You
notice the mode by observing a shaded rectangle around the shape. When
you want to change text, excel goes into this mode so you can edit
this.
-When selecting a single shape Excel goes automatically into Text Edit
mode when you start typing, when having a shape group you *first need
to select a shape within the group, and after you can start editing the
text*
- Edit mode is *not* available in VBA, as soon as VBA is active, the
"Text Edit mode" is deactivated and blocked and cannot be activated
anymore until VBA code has ended.
-The VBA characters object is only giving back text when that shape can
be given the focus (as if to start the "text editing mode")

Workaround:

Select the items within the group *before* reading out or setting the
text:

Example:

Sub t()
Dim shpTextbox As Shape
Dim tfText As TextFrame
Dim c As Characters
Dim shpGroup As Shape

Set shpGroup = ActiveSheet.Shapes(2) ' get the groupt
Set shpTextbox = shpGroup.GroupItems(1) ' get the textbox
Set tfText = shpTextbox.TextFrame
Set c = tfText.Characters()
shpTextbox.Select ' select the shape you want to get the text from,
this is important, else this code will fail!
Debug.Print c.Text ' we get the text
End Sub

Also for other types of textboxes that needs to be grouped with shapes
that do not use the "shape" textbox from the drawing toolbar, but the
textbox from the "Forms" toolbar or the "Control Toolbox" you can
safely group these with your shapes. These items can still be edited
when grouped(see my previous post). Also, you can make them mimic a
drawing textbox quite closely, so endusres will not spot the
difference, and you also can do more with them. YMMV

DM Unseen

Hope this clarifies something.

Dm Unseen