PDA

View Full Version : Solved: Looking for Tutorial on Ranges



Paul_Hossler
11-24-2009, 06:39 AM
I finally decided I needed to be a little more organized with ehe Word object model, especially with the Range object and how it's used with various types of other Word objects.

On-line help is "OK', but a little terse, and I was wondering if anyone has run across tutorial-type information on using Range object and it's properties and methods, especially since lots of other objects can have one or more Ranges as a property.

Not so much the 'easy stuff' like


Sub SetBoldRange() Dim rngDoc As Range Set rngDoc = ActiveDocument.Range(Start:=0, End:=10) rngDoc.Bold = TrueEnd Sub

but more about how Range ties in with other objects, and how to use it's methods.

For example, I didn't know about rng.MoveStartUntil. I had been doing things the hard way:(

Paul

fumei
11-24-2009, 11:21 AM
Well one way is to look at the available methods using IntelliSense, scrolling down through them one by one. They all have Help.

So, for example:

range object.m

will display

Move
MoveEnd
MoveUntil
MoveWhile
MoveStart
MoveStartUntil
MoveStartWhile
MoveUntil
MoveWhile

as choices under "m". Select one and then press F1 to get the Help. That is pretty much how I learned.

Although I certainly agree that Help can be terse.

Tinbendr
11-24-2009, 11:39 AM
"Writing Word Macros" by Steven Roman (OReilly 1999)

and MSDN (http://msdn.microsoft.com/en-us/library/2a9dt54a(VS.80).aspx)

Paul_Hossler
11-24-2009, 05:39 PM
fumei -- that only works if I know enough to look in the M's -- some days that's expecting a lot

Tinbendr -- I'll check out the book. The MSDN link is interesting, but seems to be a little 'disjoint' or a series of articles, but I'll spend more time

I thought that some one might know a KB article or something that would start at the top and work down to 'best ways' and the less often used methods. It wasn't until I started reading the forum that I found out such things as the way I was using .Find was way far from the best (most robust) way.

Paul

fumei
11-25-2009, 04:57 AM
Paul...true. I hate to say this, but what I did, was actually start at the top with the "A", and skim, through everything. Some seemed obvious so it was pretty fast skimming in places.

Range is a huge subject within Word VBA. I take one whole day teaching my VBA class just on the use of Range, and that is still no where near enough.

Truly grasping Find is a major leap in serious useability of Range, so congratulate yourself there.

Paul_Hossler
11-25-2009, 08:08 AM
Some seemed obvious so it was pretty fast skimming in places.


It's when it seems obvious, that I usually get myself in trouble, or spend 10x as must effort as I would if I just stop to think about it first.

Paul

PS: Maybe it's time to call your publisher and turn those teaching notes into the "Great Word VBA" novel so the rest of us can learn:bow:

fumei
11-25-2009, 01:15 PM
I intend to "publish" the whole course here when I retire (in about two years).