Jean-Guy ...
Sorry it took so long to respond, but my news server appears to have
taken a very long coffee break ...
Thank you again for your help, and for the explanation of my faux pas
de jour.
I am getting better at this as time goes on, but I have a bad habit of
scrounging in the microsoft.public.word.vba.* newsgroups and trying to
piece together things I find there ... without really taking the
trouble to analyze the monsters that I'm making.
The sheer number of For, Next, If and End If statements here got me
confused, and obviously I have to go back and learn more about the
Selection and Range objects. The terminology is also confusing, for
example that the Find property returns a Find object and that the Find
object has a Found property turns my head into a pretzel ...
Regards,
Sophia
Bonjour,
Dans son message, < Sophia > ?crivait :
In this message, < Sophia > wrote:
|| Jean-Guy ...
||
[quoted text clipped - 3 lines]
|| Thank you again for your help, and for the explanation of my faux pas
|| de jour.
Not at all, we all make these kind of false assumptions, or have made them
before...
|| I am getting better at this as time goes on, but I have a bad habit of
|| scrounging in the microsoft.public.word.vba.* newsgroups and trying to
Excellent way to learn!
|| piece together things I find there ... without really taking the
|| trouble to analyze the monsters that I'm making.
Oooops, not so excellent anymore! ;-)
Use the step-by-step debugger to see the code in action. What I do is set my
VBA editor to one fifth of my screen height and I put it in front of my
document. I make sure that the part of the document on which the code acts
is visible in the top 4/5th.
Then I place my cursor anywhere in the sub I want to debug and I press F8.
Each F8 will execute one line of code. Thus you can see what is going on,
you can even move the code forward (skip some lines) or re-execute some.
Sometimes what I do is go to the document and undo the last action the code
has done (Or go see the impact a couple of pages away....), go back to the
code, edit the line it just executed, grab the arrow in the code margin (the
grey border on the left) that points at the line that will be executed next
and move it back next to the line I just edited and re-execute it to see the
impact of my modification.
Also, you can set break points, e.g. If you have a long loop and do not want
to step through it line by line by doing F8 one hundred times..., put a
break point by clicking in the margin (The grey border on the left) next to
the line after the loop exit and hit F5. The code will execute to the end,
or to the next break point. Then I continue with F8...
|| The sheer number of For, Next, If and End If statements here got me
|| confused, and obviously I have to go back and learn more about the
|| Selection and Range objects. The terminology is also confusing, for
If you plan on doing more coding, the Range object is a must.
|| example that the Find property returns a Find object and that the Find
|| object has a Found property turns my head into a pretzel ...
The Find properties are, if you want, the parameters that determine how the
find will be executed (forward, replace text or not, checking for case,
etc.) The Found property is just the result of the find... was it successful
or not. But as you saw with the example I posted, you can use the Execute to
achieve the same result.
Good luck!

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Sophia - 29 Jun 2004 11:50 GMT
Jean-Guy ...
Thank you for your kind advice ... especially the section below, which
I had never thought of. I had been switching back and forth between
full-screen copies of the document and the VB editor ... and just
trying to imagine what had been going on "behind the scenes."
Such a *great* idea ... and something I'd never seen in any of the
books I've read. It's one of those things in life that "should be
obvious," I suppose ... but wasn't for me, and I can't begin to tell
you how much of an asset it will be in the future ...
The idea of single-stepping through the code with everything
visible!!! Good grief!
It reminds me of the time I was in the supermarket, trying to get one
of those big leafy heads of lettuce into one of those diaphanous
plastic bags ... folding over the leaves (which were headed in all
directions) ... trying to manage the whole mess without breaking too
many ... and cussing to myself as I always did in that same situation
... week after week.
There was a sprightly little old Chinese woman standing next to me,
looking at me as if I'd just landed there from another planet ... with
a gleam in her eye. She took the bag from me, put her right hand
*into* the bag, pulling the top edges in the direction of her elbow
... then took the lettuce with her left hand and placed the root-end
into her bag-covered right hand ... then pulled the bag down, *over*
the lettuce without breaking a single leaf.
I stood there in complete amazement ... and when I finally got my
brain back in gear, I said to her, "How on earth did I live *all*
these years without thinking of *that*?" She responded with a
wonderful smile ... and without saying a single word ... went on her
way.
Since then, I've offered her idea to several others who I saw
struggling in the same situation ... and just a minute ago, I stored a
Google link to your message and will share it as often as I can with
others whose unmanageable code is hanging out in all directions like
mine was ...
Kind regards,
Sophia
<clip>
>Use the step-by-step debugger to see the code in action. What I do is set my
>VBA editor to one fifth of my screen height and I put it in front of my
[quoted text clipped - 14 lines]
>the line after the loop exit and hit F5. The code will execute to the end,
>or to the next break point. Then I continue with F8...
<clip
Jean-Guy Marcil - 29 Jun 2004 13:38 GMT
Bonjour,
Dans son message, < Sophia > ?crivait :
In this message, < Sophia > wrote:
|| Jean-Guy ...
||
[quoted text clipped - 37 lines]
|| others whose unmanageable code is hanging out in all directions like
|| mine was ...
Glad I could help!
If you are not already doing so, you should consider a carer in
writing.Really enjoy reading your story!

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Sophia - 01 Jul 2004 00:19 GMT
Jean-Guy ...
Thank you for the compliment about my writing. I don't know about a
career doing it ... I wouldn't know quite how to find my way in that
direction, but I do get a lot of practice in
microsoft.public.word.vba.beginners, trying to make myself understood.
I mean ... trying to explain what I'm attempting to accomplish in a
program when I get hopelessly tangled in it ... as I was at the
beginning of this thread. Often, just explaining it to myself gives
me the clues I need. But more often I end up here, trying to explain
how I tried to get my leafy head of lettuce in the plastic bag ... the
wrong way.
KRegards,
Sophia
>Glad I could help!
>
>If you are not already doing so, you should consider a carer in
>writing.Really enjoy reading your story!