Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default XL2007 Bug: Text Can be Changed in Shape with Linked Text

First, a reminder: To create a shape with linked text, enter "Hello" in,
say, cell A1, add an autoshape to the sheet, select that shape, click in the
formula bar, and enter "=A1". The shape now displays "Hello". If you
right-click on the shape, the "Edit Text" option is grayed-out.
To see the problem, with the shape selected, run the following in the
immediate window:
selection.shaperange(1).textframe2.textrange.text = "Goodbye"
The shape now says "Goodbye", with, e.g., "=A1" showing in the formula bar.
Recalculating (Ctrl + Alt + F9) does not change this. Clicking in the
formula bar, then pressing enter will redisplay the linked text.
To avoid this problem, programmers need to be able to tell if a shape has
linked text. I find no direct way of determining this. Here is a
work-around, illustrated in the immediate window:
? selection.shaperange(1).textframe2.textrange.chara cters(1,1).count
For a non-linked shape, the above gives the expected result: 1. For a
linked shape, the above gives the number of characters in the linked text:
5, if the linked text is "Hello"; not what you'd expect for .characters(1,1).
I've found no way to tell if text is linked if it only contains one
character, so I've had to exclude formatting one-character text. Here's an
example of how to handling this:

For N = 1 To Selection.ShapeRange.Count
Set Shp = Selection.ShapeRange(N)
With Shp
nShpType = .Type
If nShpType = msoAutoShape Or nShpType = msoTextBox _
Or nShpType = msoComment Then
If .TextFrame2.HasText Then
If .TextFrame2.TextRange.Characters(1, 1).Count = 1 And
.TextFrame2.TextRange.Characters.Count 1 Then
DoFormat .TextFrame 'Formats the shapes text
End If
End If
End If
End With
Next N


Chris

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
xl2007 text import tool Eddie O Excel Discussion (Misc queries) 1 July 19th 07 03:24 AM
Moving a shape with text inside without editing text Dan Excel Programming 3 March 10th 07 11:33 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Cutting and pasting large variable text into a text box shape usin AJL Excel Programming 0 October 30th 06 06:54 PM
Text not fully displayed when text direction changed Mikey9131 Excel Discussion (Misc queries) 3 November 30th 05 12:09 PM


All times are GMT +1. The time now is 06:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"