atw: Re: Insert wrapper text VBA for Geoffrey

  • From: Steve Hudson <sh1448291904@xxxxxxxxx>
  • To: austechwriter@xxxxxxxxxxxxx
  • Date: Fri, 5 Dec 2014 17:38:39 +1100

Dear Howard,

> What, no text?

Yar - he said he was using LaTex.


> But Geoffrey's question was: "Is it possible with VBA to
wrap *selected text* in some specified characters?"

Ha, he was using user speak, and as TWs we need to translate back and forth
between user speak and dev speak.


> But I can't understand why you're so keen to avoid "interfering with the
selected range"

It's a stylist thing for the point of illustration of how range objects
work. Most people who whack out a bit of BASIC would be used to something
like:

X=5
Y=X

Y=Y+3
debug.print X

which would yield 5, but if x and y were ranges, it would return the
equivalent of 8. This unusual programming point is lost on a lot of people,
and I have seen it cause chaos in peoples code attempts on numerous
occasions.

Additionally, if we are going to write a private function, it should
certainly be separated from selection for those times when it's going to be
called recursively. It also then allows for easy extension for special
styling of the inserted text. Sure, I agree, its arguably overkill for this
trivial solution, but written my way it forms a neat little function for
all sorts of use - even in building your own xml structures if you're crazy
enough to do it inline. Also, to duplicate a range is low overhead, it only
has to copy 2 numbers (start and end) to the new object.

I'll be discussing all this and more in an instructional video once my
hardware arrives. ;-p

Steve

Other related posts: