Word VBA >> Marking and Looping

by Chad DeMeyer » Thu, 15 Jul 2004 23:39:14 GMT

Silvio,

Please see my reply to your original post.

cjd


"Silvio" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> Hello experts! I need some help in finalize the code below. It is supposed
to automatically "Mark Entry", for index purpose, all the words in a
document. The problem is that it starts ok, however, after properly
selecting the first few words then starts repeating the same word and over
again. Any idea?
>
> Dim oWord As Range
> For Each oWord In ActiveDocument.Words
> Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
> ActiveWindow.ActivePane.View.ShowAll = True
> ActiveDocument.Indexes.MarkEntry Range:=Selection.Range,
Entry:=Selection.Range, _
> EntryAutoText:=Selection.Range
> 'Selection.MoveRight Unit:=wdCharacter, Count:=1
> Next oWord




Similar Threads

1. loop and end loop

Can anyone help. I have a 15 thousand line spread sheet that requires me to 
take certain information and bring it up to the same line as the first 
instance of a product. I have written a macro that works fine. However I am 
trying to loop it to do the whole sheet. I can 't seem to make the loop work 
even with the help function. The code is as follows:
do loop

   ActiveCell.Offset(0, 4).Range("A1").Select
    Selection.Copy
    ActiveCell.Offset(0, 3).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, -2).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(0, 3).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, -2).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(0, 3).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(1, -5).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-1, 6).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(1, -5).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-1, 6).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(1, -5).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-1, 6).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(2, -8).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-2, 9).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(2, -8).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-2, 9).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(2, -8).Range("A1").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-2, 9).Range("A1").Select
    ActiveSheet.Paste
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
    Selection.Delete Shift:=xlUp
    ActiveCell.Select
   Loop Until ActiveCell(A1409)

It complains that I am not using a do, but I think I am, it is there, it 
just doesn't seem to think it is.

Any help would be greatly appriciated.

Thanks

2. Why Doesn't This Loop-within-a-Loop Work? - MS Word&VBA

3. Loops within Loops.

I have started what is (for me) an ambitious project and 
am having trouble visualising a central Procedure. 
Deceptively simple, the exact solution eludes me for the 
moment. Can someone help with the coding, please?

Sub "RedWord" starts with the one-page Active Document 
displayed. The user clicks once on a word. The word is 
automatically selected and turned red. Clicks on further 
words are made, with the mouse-click starting each new 
loop. All the selected words remain red until replaced, 
see below. Clicking again on a (now red) word causes it 
to revert to its original color, so some sort of toggle 
is needed here. (One must allow for a change of mind.) 
Realistically we may have 15 - 18 red, single words in 
the final displayed document. The sequence of loops ends 
when the Return key is pressed.

Parallel with, or after, the above, I need to build up a 
string of all the single words finally chosen. However, 
the words must first be sorted alphabetically. They are 
then joined in a string with a <sp>/<sp> separator 
between each (but no separator before the first word or 
after the last). In a later Sub this string will be 
printed back into the doc, so how do I make it available 
to that Sub?  In the present Sub it is displayed in a 
Message Box when the Return Key terminates the loops.

Finally, after the Message Box has gone, I need to 
replace each of the "Redwords" in the text with a series 
of underscore characters only partly dependent on the 
length of the Redword, as follows:
  If Redword is 4 charas long or less,  6 underscores; 
  If Redword is from 5 - 10 charas,    12 underscores;
  If Redword is 11 or more charas, underscores = Length 
of Redword + 2 .  The underscores, when displayed, should 
not be coloured.

I will be most grateful for any help.  Thanks a lot.






4. Loop de loop - MS Word&VBA

5. Loop not Looping

I am relatively new to writing macros and have a feeling I am missing one 
step, but I am trying to write a macro that searches up for an occurrence of 
the word article followed by a space and any number and another space.  I 
then want it to delete the space, and insert a tab.  The macro works fine, 
but for some reason, it is not looping.  If you have any suggestions, I would 
greatly appreciate it.  here is what I have so far:

Selection.HomeKey Unit:=wdStory
    Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
    Selection.Find.ClearFormatting
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Selection.MoveDown Unit:=wdLine, Count:=1
    Do
    With Selection.Find
        .Text = "article ^# "
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeBackspace
    Selection.TypeText Text:=vbTab
    Loop Until Condition = False
 End Sub

6. Marking Checkbox from VBA - Excel

7. Marking a folder as 'no sync'

Is there a way to mark a folder so that it will not sync back to exchange?

8. Marking all future contacts that are created Private