nested grinding..

M

mr.anderson

Hello there!

I need an example for an nested grinding..
I don't know how to think about, so I don't know any example...
If I would have some (simple) examples I think that I would better
understand the backgrounds.

would be nice if you could help me!

thx,
Mr.Anderson
 
D

Doug Robbins

What's a "nested grinding"? It's not a term that I have ever heard of in
connection with Word. Did you mean "nested table"?

If so, that is when you insert a table inside a cell of another table. I've
never had a use for it.

If that is what you are talking about, it would be better to ask in the
microsoft.public.word.tables newsgroup.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
J

Jezebel

Google gives exactly one hit for "nested grinding" -- an arcane reference
relating to optical engineering. The relevance to Word is obscure to say the
least.
 
M

Malcolm Smith

Sounds like the hopes and anticipations of a young man in a nightclub on a
Friday night, whose hormones are alive and kicking...
 
M

mr.anderson

o.k.
I think there is an small problem with the translation ;)
I ment a loop (for example FOR, or DO loop) which is inserted in another
loop .."nested"!?
hope you understand this..

thx again..
Mr.Anderson
 
D

Doug Robbins

There's a nested "For ... Next" in the following macro:

' Macro to create multiple items per condition in separate tables from a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat <> tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i

For a Do While ..Loop, it would be structured as follows (this is not an
actual macro, just modified to show how it would fit together.


Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,}.[0-9]{3,}", MatchWildcards: =
True, Wrap:=wdFindContinue, Forward:=True) = True
Do While [condition]
'commands
Loop
Loop
End With

With nested commands, once an inner procedure is encountered, it is in
control while it's condition is true and control is not returned to the
outer procedure until the inner procedure has run its course.


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
E

Eric

Do you mean nested looping?

Like this:
For ii = 1 to 10
For jj = 1 to 20
Rem do inner loop stuff here.
Next jj
Next ii
 
J

Jezebel

It's slightly more efficient (although probably not significant) if you omit
the variable after the Next

for i = 1 to 10
....
Next

The reason being that if the variable is there, VB has to validate, each
time, that it's the correct loop index; if the variable is missing it uses
the current index. This is an artefact of early basic which provided (and VB
still supports) horrid constructions like:

For ii = 1 to 10
For jj = 1 to 20
....
Next jj, ii
 
D

Doug Robbins

But when dealing with nested For ... Next constructions, I think it makes it
more intelligible to the "user" if the variable is included after the Next.
Otherwise the "user" had to validate ...

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
J

Jezebel

The recommendation in the KB article is to insert the variable as a comment
....

For ii = 1 to 10
...
Next 'ii

Probably makes almost no difference for most purposes, but some loops get
run a LOT of times (especially if the loops are nested!), so it does matter
occasionally.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top