View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Editing text in text box grouped within a trapezoid

Hi DM,

I think we are still talking at cross purposes <g

The OP's objective is to write text in a grouped shape that has a text
frame. It's easy to return the text in such an item, in your example no need
to select anything vs what your commented notes suggest "...or the code will
fail".

However - how to write text without ungrouping. Your example does not do
that and I don't think possible.

Further, both you and the OP suggest it's possible to manually edit text in
a grouped item without ungrouping. I guess I must be missing something
because I don't see any way to do that.

Regards,
Peter T

PS, I was aware that your original example with controlformat did not
ungroup, and also that it's possible to change just about anything in a
grouped object except text, though individual font proeprties are also a
problem.


"DM Unseen" wrote in message
oups.com...
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