PC Review


Reply
Thread Tools Rate Thread

Autosize bug in Excel 2007 shape textframes

 
 
Anthony Berglas
Guest
Posts: n/a
 
      25th Apr 2007
XL 2007 only seems to AutoSize the Height of a text box, not the
Width.
This is different from XL 95..2003 which autosized both.

This is easily seen from the UI, just create an Autoboxed frame and
type into it, only in XL < 2007 does it get wider.

This makes it difficult to programatically create a text box, and put
some text in it and have the box displayed in a natural width. Same
goes for comments etc.

Any ideas for a work around most appreciated. (Guessing the width of
fonted strings is very error prone.)

Regards,

Anthony

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      25th Apr 2007
Anthony,
I don't use XL2007, but does it jog the Text frame to the correct size if
you toggle the AutoSize property:

With <YourTextFrame>
.Characters.Text = "Some long line of text spread" & Chr(10) & "over
several" & Chr(10) & "lines"
.AutoSize=false
.AutoSize=true
End with

NickHK

"Anthony Berglas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> XL 2007 only seems to AutoSize the Height of a text box, not the
> Width.
> This is different from XL 95..2003 which autosized both.
>
> This is easily seen from the UI, just create an Autoboxed frame and
> type into it, only in XL < 2007 does it get wider.
>
> This makes it difficult to programatically create a text box, and put
> some text in it and have the box displayed in a natural width. Same
> goes for comments etc.
>
> Any ideas for a work around most appreciated. (Guessing the width of
> fonted strings is very error prone.)
>
> Regards,
>
> Anthony
>



 
Reply With Quote
 
Anthony Berglas
Guest
Posts: n/a
 
      26th Apr 2007
Good idea, but I just tried it and no, that does not work.

The behavior for comment frames seems slightly different to text boxes,
still investigating.

If anyone knows how to write a WidthOfFontedString(characters) then that
would be great.

(And I have set up a "real" news reader, apologies for the multiple
posts. And all the messages now show up on Google. But not in the
search index. I must have just missed them when I checked this morning.)

Thanks,

Anthony

NickHK wrote:

> Anthony,
> I don't use XL2007, but does it jog the Text frame to the correct size if
> you toggle the AutoSize property:
>
> With <YourTextFrame>
> .Characters.Text = "Some long line of text spread" & Chr(10) & "over
> several" & Chr(10) & "lines"
> .AutoSize=false
> .AutoSize=true
> End with
>
> NickHK
>
> "Anthony Berglas" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>XL 2007 only seems to AutoSize the Height of a text box, not the
>>Width.
>>This is different from XL 95..2003 which autosized both.
>>
>>This is easily seen from the UI, just create an Autoboxed frame and
>>type into it, only in XL < 2007 does it get wider.
>>
>>This makes it difficult to programatically create a text box, and put
>>some text in it and have the box displayed in a natural width. Same
>>goes for comments etc.
>>
>>Any ideas for a work around most appreciated. (Guessing the width of
>>fonted strings is very error prone.)
>>
>>Regards,
>>
>>Anthony
>>

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      26th Apr 2007
Anthony,
One way, in a cell out of the way somewhere, insert the desired text in the
correct font, size, formatting etc. Then AutoSize the column. Read the
column width.
You may have to use some scaling factor to convert to the units/differences
between the worksheet cell and a Text Frame, but at least it should be
constant.
Otherwise, use a fixed width font and no formatting and just multiply by the
number of characters, if this is practical for you.

NickHK

"Anthony Berglas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Good idea, but I just tried it and no, that does not work.
>
> The behavior for comment frames seems slightly different to text boxes,
> still investigating.
>
> If anyone knows how to write a WidthOfFontedString(characters) then that
> would be great.
>
> (And I have set up a "real" news reader, apologies for the multiple
> posts. And all the messages now show up on Google. But not in the
> search index. I must have just missed them when I checked this morning.)
>
> Thanks,
>
> Anthony
>
> NickHK wrote:
>
> > Anthony,
> > I don't use XL2007, but does it jog the Text frame to the correct size

if
> > you toggle the AutoSize property:
> >
> > With <YourTextFrame>
> > .Characters.Text = "Some long line of text spread" & Chr(10) & "over
> > several" & Chr(10) & "lines"
> > .AutoSize=false
> > .AutoSize=true
> > End with
> >
> > NickHK
> >
> > "Anthony Berglas" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >
> >>XL 2007 only seems to AutoSize the Height of a text box, not the
> >>Width.
> >>This is different from XL 95..2003 which autosized both.
> >>
> >>This is easily seen from the UI, just create an Autoboxed frame and
> >>type into it, only in XL < 2007 does it get wider.
> >>
> >>This makes it difficult to programatically create a text box, and put
> >>some text in it and have the box displayed in a natural width. Same
> >>goes for comments etc.
> >>
> >>Any ideas for a work around most appreciated. (Guessing the width of
> >>fonted strings is very error prone.)
> >>
> >>Regards,
> >>
> >>Anthony
> >>

> >
> >
> >



 
Reply With Quote
 
Anthony Berglas
Guest
Posts: n/a
 
      27th Apr 2007
Hmm, clever idea. And I just checked that it still works in XL07. But
what a hack! And performance is passable -- about 5 ms per AutoFit.

I am also comming across bugs in .characters() functions. Nasty,
unrepeatable corrupting ones. I suspect that they have been lurking
since XL95, (and I have ugly work arounds) but are just corrumpting
memory that happens to be more important now.

Anthony

NickHK wrote:

> Anthony,
> One way, in a cell out of the way somewhere, insert the desired text in the
> correct font, size, formatting etc. Then AutoSize the column. Read the
> column width.
> You may have to use some scaling factor to convert to the units/differences
> between the worksheet cell and a Text Frame, but at least it should be
> constant.
> Otherwise, use a fixed width font and no formatting and just multiply by the
> number of characters, if this is practical for you.
>
> NickHK
>
> "Anthony Berglas" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>Good idea, but I just tried it and no, that does not work.
>>
>>The behavior for comment frames seems slightly different to text boxes,
>>still investigating.
>>
>>If anyone knows how to write a WidthOfFontedString(characters) then that
>>would be great.
>>
>>(And I have set up a "real" news reader, apologies for the multiple
>>posts. And all the messages now show up on Google. But not in the
>>search index. I must have just missed them when I checked this morning.)
>>
>>Thanks,
>>
>>Anthony
>>
>>NickHK wrote:
>>
>>
>>>Anthony,
>>>I don't use XL2007, but does it jog the Text frame to the correct size

>
> if
>
>>>you toggle the AutoSize property:
>>>
>>>With <YourTextFrame>
>>> .Characters.Text = "Some long line of text spread" & Chr(10) & "over
>>>several" & Chr(10) & "lines"
>>> .AutoSize=false
>>> .AutoSize=true
>>>End with
>>>
>>>NickHK
>>>
>>>"Anthony Berglas" <(E-Mail Removed)> wrote in message
>>>news:(E-Mail Removed)...
>>>
>>>
>>>>XL 2007 only seems to AutoSize the Height of a text box, not the
>>>>Width.
>>>>This is different from XL 95..2003 which autosized both.
>>>>
>>>>This is easily seen from the UI, just create an Autoboxed frame and
>>>>type into it, only in XL < 2007 does it get wider.
>>>>
>>>>This makes it difficult to programatically create a text box, and put
>>>>some text in it and have the box displayed in a natural width. Same
>>>>goes for comments etc.
>>>>
>>>>Any ideas for a work around most appreciated. (Guessing the width of
>>>>fonted strings is very error prone.)
>>>>
>>>>Regards,
>>>>
>>>>Anthony
>>>>
>>>
>>>
>>>

>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      27th Apr 2007
Anthony,
I have no pressing need for Office2007. I'm waiting for an SP or 2 before
<upgrading>.
I'll let you folks figure out the difficult bits before I jump aboard <g>.

NickHK

"Anthony Berglas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hmm, clever idea. And I just checked that it still works in XL07. But
> what a hack! And performance is passable -- about 5 ms per AutoFit.
>
> I am also comming across bugs in .characters() functions. Nasty,
> unrepeatable corrupting ones. I suspect that they have been lurking
> since XL95, (and I have ugly work arounds) but are just corrumpting
> memory that happens to be more important now.
>
> Anthony
>
> NickHK wrote:
>
> > Anthony,
> > One way, in a cell out of the way somewhere, insert the desired text in

the
> > correct font, size, formatting etc. Then AutoSize the column. Read the
> > column width.
> > You may have to use some scaling factor to convert to the

units/differences
> > between the worksheet cell and a Text Frame, but at least it should be
> > constant.
> > Otherwise, use a fixed width font and no formatting and just multiply by

the
> > number of characters, if this is practical for you.
> >
> > NickHK
> >
> > "Anthony Berglas" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >
> >>Good idea, but I just tried it and no, that does not work.
> >>
> >>The behavior for comment frames seems slightly different to text boxes,
> >>still investigating.
> >>
> >>If anyone knows how to write a WidthOfFontedString(characters) then that
> >>would be great.
> >>
> >>(And I have set up a "real" news reader, apologies for the multiple
> >>posts. And all the messages now show up on Google. But not in the
> >>search index. I must have just missed them when I checked this

morning.)
> >>
> >>Thanks,
> >>
> >>Anthony
> >>
> >>NickHK wrote:
> >>
> >>
> >>>Anthony,
> >>>I don't use XL2007, but does it jog the Text frame to the correct size

> >
> > if
> >
> >>>you toggle the AutoSize property:
> >>>
> >>>With <YourTextFrame>
> >>> .Characters.Text = "Some long line of text spread" & Chr(10) &

"over
> >>>several" & Chr(10) & "lines"
> >>> .AutoSize=false
> >>> .AutoSize=true
> >>>End with
> >>>
> >>>NickHK
> >>>
> >>>"Anthony Berglas" <(E-Mail Removed)> wrote in message
> >>>news:(E-Mail Removed)...
> >>>
> >>>
> >>>>XL 2007 only seems to AutoSize the Height of a text box, not the
> >>>>Width.
> >>>>This is different from XL 95..2003 which autosized both.
> >>>>
> >>>>This is easily seen from the UI, just create an Autoboxed frame and
> >>>>type into it, only in XL < 2007 does it get wider.
> >>>>
> >>>>This makes it difficult to programatically create a text box, and put
> >>>>some text in it and have the box displayed in a natural width. Same
> >>>>goes for comments etc.
> >>>>
> >>>>Any ideas for a work around most appreciated. (Guessing the width of
> >>>>fonted strings is very error prone.)
> >>>>
> >>>>Regards,
> >>>>
> >>>>Anthony
> >>>>
> >>>
> >>>
> >>>

> >
> >



 
Reply With Quote
 
Anthony Berglas
Guest
Posts: n/a
 
      28th Apr 2007
> Anthony,
> I have no pressing need for Office2007. I'm waiting for an SP or 2 before
> <upgrading>.


Very wise. But I am writing an add-in for others so do not have that
luxury.

To be fair, the released version is much beter than the final "Beta 2
Technical Refresh". They addressed a number of bugs that I had reported
(no idea whether my bug lists were ever read or they were working from
their own lists).

I have hacked Autosize by just second guessing text widths in plain
code, taking account of narrower characters etc. Rough but adequate.
I'm a little worried that in SP1 or 2 they will "fix" Autosize to work
the way it used to work, and break my code again! (I'd say that at
least 90% of my development time is working around quirks like these
plus weird optimizations that prove necessary.)

One note is that the text boxes in Comments do AutoSize the traditional
way, height and width.

Anthony

NickHK wrote:

> Anthony,
> I have no pressing need for Office2007. I'm waiting for an SP or 2 before
> <upgrading>.
> I'll let you folks figure out the difficult bits before I jump aboard <g>.
>
> NickHK
>
> "Anthony Berglas" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>Hmm, clever idea. And I just checked that it still works in XL07. But
>>what a hack! And performance is passable -- about 5 ms per AutoFit.
>>
>>I am also comming across bugs in .characters() functions. Nasty,
>>unrepeatable corrupting ones. I suspect that they have been lurking
>>since XL95, (and I have ugly work arounds) but are just corrumpting
>>memory that happens to be more important now.
>>
>>Anthony
>>
>>NickHK wrote:
>>
>>
>>>Anthony,
>>>One way, in a cell out of the way somewhere, insert the desired text in

>
> the
>
>>>correct font, size, formatting etc. Then AutoSize the column. Read the
>>>column width.
>>>You may have to use some scaling factor to convert to the

>
> units/differences
>
>>>between the worksheet cell and a Text Frame, but at least it should be
>>>constant.
>>>Otherwise, use a fixed width font and no formatting and just multiply by

>
> the
>
>>>number of characters, if this is practical for you.
>>>
>>>NickHK
>>>
>>>"Anthony Berglas" <(E-Mail Removed)> wrote in message
>>>news:(E-Mail Removed)...
>>>
>>>
>>>>Good idea, but I just tried it and no, that does not work.
>>>>
>>>>The behavior for comment frames seems slightly different to text boxes,
>>>>still investigating.
>>>>
>>>>If anyone knows how to write a WidthOfFontedString(characters) then that
>>>>would be great.
>>>>
>>>>(And I have set up a "real" news reader, apologies for the multiple
>>>>posts. And all the messages now show up on Google. But not in the
>>>>search index. I must have just missed them when I checked this

>
> morning.)
>
>>>>Thanks,
>>>>
>>>>Anthony
>>>>
>>>>NickHK wrote:
>>>>
>>>>
>>>>
>>>>>Anthony,
>>>>>I don't use XL2007, but does it jog the Text frame to the correct size
>>>
>>>if
>>>
>>>
>>>>>you toggle the AutoSize property:
>>>>>
>>>>>With <YourTextFrame>
>>>>> .Characters.Text = "Some long line of text spread" & Chr(10) &

>
> "over
>
>>>>>several" & Chr(10) & "lines"
>>>>> .AutoSize=false
>>>>> .AutoSize=true
>>>>>End with
>>>>>
>>>>>NickHK
>>>>>
>>>>>"Anthony Berglas" <(E-Mail Removed)> wrote in message
>>>>>news:(E-Mail Removed)...
>>>>>
>>>>>
>>>>>
>>>>>>XL 2007 only seems to AutoSize the Height of a text box, not the
>>>>>>Width.
>>>>>>This is different from XL 95..2003 which autosized both.
>>>>>>
>>>>>>This is easily seen from the UI, just create an Autoboxed frame and
>>>>>>type into it, only in XL < 2007 does it get wider.
>>>>>>
>>>>>>This makes it difficult to programatically create a text box, and put
>>>>>>some text in it and have the box displayed in a natural width. Same
>>>>>>goes for comments etc.
>>>>>>
>>>>>>Any ideas for a work around most appreciated. (Guessing the width of
>>>>>>fonted strings is very error prone.)
>>>>>>
>>>>>>Regards,
>>>>>>
>>>>>>Anthony
>>>>>>
>>>>>
>>>>>
>>>>>
>>>

>
>

 
Reply With Quote
 
Bob Flanagan
Guest
Posts: n/a
 
      13th May 2007
Greetings Anthony. One thought: Write the text out to a column and auto
size the column. This should give you width to use in the text box.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Anthony Berglas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> XL 2007 only seems to AutoSize the Height of a text box, not the
> Width.
> This is different from XL 95..2003 which autosized both.
>
> This is easily seen from the UI, just create an Autoboxed frame and
> type into it, only in XL < 2007 does it get wider.
>
> This makes it difficult to programatically create a text box, and put
> some text in it and have the box displayed in a natural width. Same
> goes for comments etc.
>
> Any ideas for a work around most appreciated. (Guessing the width of
> fonted strings is very error prone.)
>
> Regards,
>
> Anthony
>



 
Reply With Quote
 
Nick Hebb
Guest
Posts: n/a
 
      13th May 2007

Anthony Berglas wrote:
> XL 2007 only seems to AutoSize the Height of a text box, not the
> Width.
> This is different from XL 95..2003 which autosized both.
>


I have to admit, this statement leaves me stumped. I have never been
able to get the autosize feature to work properly in Excel <= 2003.
Whenever I use the autosize feature in the Format Shape window, it
automatically sizes the width, but all the text is in a single line.
Was there another method that I have been missing out on?

To get autosizing to work in my add-in, I spent many hours writing my
own algorithm. If there's an easier way, I'm going to be really ticked
at myself.

In fact, I though the TextFrame2 Autosize method in 2007 was a
Godsend.


Nick Hebb
BreezeTree Software
http://www.,breezetree.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 - Rows - Height - AutoSize question John Microsoft Excel Misc 1 22nd Oct 2011 06:33 PM
shape, textbox, autosize vertically 2007 Gab Microsoft Excel Programming 2 14th Jul 2008 06:10 PM
Shape top position in Excel 2007 Chris Bruce Microsoft Excel Programming 4 2nd Apr 2008 08:48 PM
Autosize bug in Excel 2007, textboxes, work arounds Anthony Berglas Microsoft Excel Programming 1 26th Apr 2007 04:28 AM
Autosize bug workarounds in Excel 2007 shape textframes Anthony Berglas Microsoft Excel Programming 0 25th Apr 2007 07:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:53 PM.