View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] baobob@my-deja.com is offline
external usenet poster
 
Posts: 100
Default How do you find WHERE Excel splits your wrapped string?

Peter T:

OK, I’ve played around a lot with your code, but I have so many
questions I must stop for the moment.

(Answer only if inclined:)

1. First and foremost, what I really need is, not code but a simple
statement of whether what I want can be done or not.

Ideally I want a formula "=MyWrap(X)" where X can be a string *or* a
cell address of a string, which returns the string wrapped 'n
indented.

Your code’s great & does this in a Sub (which I executed via Tools /
Macros--I assume that was correct). But a Sub doesn’t “return” the
result; it “calculates” it in real time inputting it anew in a cell.
After which the original string--however you passed it into the Sub--
is gone, right? But I’ve got hundreds of cell references to strings,
and those strings can change.

2. I’ve been a heavy Excel user for years, and I’d never heard of a
TextBox. However, after making yours visible I certainly grasped it,
and why you’re using it--i.e. as a buffer to measure when my string
exceeds its width.

But if a TextBox is required because a cell or range *itself* has no
useful property that you can apply to string length calculation, then:
Why? Is Redmond’s answer “42”?

3. On a similar score, I must beg your indulgence by asking, possibly
again and possibly dumbly: how does "column autofit", which you've
mentioned at times, enter into my problem? I need to wrap strings in a
column whose width is fixed. I'm not trying to determine what "column
width" a string "requires".

If on the other hand you're suggesting column autofit to somehow help
determine where Excel splits a string when wrapping, then...well, how
would that work? But at this point it might be tangential to the
current thread.

4. In trying to run your code as a UDF, the TextBox seemed to get
created OK, but any attempt to set any TB properties failed and was
totally ignored. E.g. if TB.TextFrame.Characters.Text was, say, "abc",
then command TB.TextFrame.Characters.Text = "xyz" did nothing and the
value remained "abc". And the compiler or interpreter (whatever the
term is) failed to warn me about it.

Is this failure by any chance related to the use of a Function instead
of a Sub? I’ve often seen the statement that some things just can’t be
done in a function.

5. You’re sizing the TB 5 units narrower than the cell. Is that some
magical number? Or a fudge factor of some sort?

Thanks much again if you read this.

***