selection.find wrap options 
Author Message
 selection.find wrap options

Hi Jeff,

AFAIK, wdFindContinue will not put you into an infinite loop all by itself.
I suspect there's something else in your routine that causes the loop. Can
you share the revelant portion of your routine?


Quote:
> 1) For a Selection.Find, what can I set the Wrap option to
> in order to make the search stop when it reaches the end
> of file. I get into an infinite loop. My current Wrap
> option is set to wdFindContinue, which I think is the
> problem. But I don't know the other values I can set it to.

> 2) Is there an online VBA reference where I can find such
> information? For some reason, when I use my company's
> networked MS Word, and I go to Microsoft Visual Basic
> Help, I can go to the Contents tab, but when I try to go
> to the Index or Answer Wizard tab, I get a horizontal,
> double-headed arrow and cannot type text into the field.

> Jeff



Sat, 07 May 2005 00:47:11 GMT  
 selection.find wrap options
Hi Jeff,

Try the following instead:

With Selection
    .HomeKey unit:=wdStory
    With .Find
        .ClearFormatting
        .Text = "Step Name"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        ' while it can find each new instance of
        ' "Step Name"
        Do While .Execute
            With Selection
                With .Tables(1).Columns(1)
                    .PreferredWidthType = wdPreferredWidthPoints
                    .PreferredWidth = InchesToPoints(0.6)
                End With
                .Move unit:=wdColumn, Count:=1
                .SelectColumn
                With .Columns
                    .PreferredWidthType = wdPreferredWidthPoints
                    .PreferredWidth = InchesToPoints(4.7)
                End With
                .Move unit:=wdColumn, Count:=1
                .SelectColumn
                With .Columns
                    .PreferredWidthType = wdPreferredWidthPoints
                    .PreferredWidth = InchesToPoints(4.7)
                End With
                .MoveDown unit:=wdLine, Count:=1
            End With
Loop
    End With
End With

HTH

Quote:
> It isn't pretty, but the entire macro that I run in Word
> is below.

> Jeff

> Sub ResizeAllTablesInDocument()
> '
> ' ResizeAllTablesInDocument Macro
> ' Macro recorded 11/18/2002 by Jeff Rupprecht
> ' Search for tables with Step Name as first column name.
> ' Then resize the table and go on to the next table, until
> end of file.
> '
> Do While True = True ' Basically, loop until "If"
> statement ends loop.
> Selection.Find.ClearFormatting
>     With Selection.Find
>         .Text = "Step Name"
>         .Replacement.Text = ""
>         .Forward = True
>         .Wrap = wdFindContinue
>         .Format = False
>         .MatchCase = True
>         .MatchWholeWord = False
>         .MatchWildcards = False
>         .MatchSoundsLike = False
>         .MatchAllWordForms = False
>     End With
>     Selection.Find.Execute
> ' If table column "Step Name" not found
>     If Selection.Find.Found = False Then
>         Exit Do    ' Exit loop.
>     End If
> ' If table column "Step Name" found
>     Selection.Tables(1).Columns(1).PreferredWidthType =
> wdPreferredWidthPoints
>     Selection.Tables(1).Columns(1).PreferredWidth =
> InchesToPoints(0.6)
>     Selection.Move Unit:=wdColumn, Count:=1
>     Selection.SelectColumn
>     Selection.Columns.PreferredWidthType =
> wdPreferredWidthPoints
>     Selection.Columns.PreferredWidth = InchesToPoints(4.7)
>     Selection.Move Unit:=wdColumn, Count:=1
>     Selection.SelectColumn
>     Selection.Columns.PreferredWidthType =
> wdPreferredWidthPoints
>     Selection.Columns.PreferredWidth = InchesToPoints(4.7)
>     Selection.MoveDown Unit:=wdLine, Count:=1
> Loop
> End Sub
> >-----Original Message-----
> >Hi Jeff,

> >AFAIK, wdFindContinue will not put you into an infinite
> loop all by itself.
> >I suspect there's something else in your routine that
> causes the loop. Can
> >you share the revelant portion of your routine?



> >> 1) For a Selection.Find, what can I set the Wrap option
> to
> >> in order to make the search stop when it reaches the end
> >> of file. I get into an infinite loop. My current Wrap
> >> option is set to wdFindContinue, which I think is the
> >> problem. But I don't know the other values I can set it
> to.

> >> 2) Is there an online VBA reference where I can find
> such
> >> information? For some reason, when I use my company's
> >> networked MS Word, and I go to Microsoft Visual Basic
> >> Help, I can go to the Contents tab, but when I try to go
> >> to the Index or Answer Wizard tab, I get a horizontal,
> >> double-headed arrow and cannot type text into the field.

> >> Jeff

> >.



Sat, 07 May 2005 01:33:47 GMT  
 selection.find wrap options
Dave,

Thanks a lot. Your program structure was much more elegant
than mine. And it worked great. Would you happen to have a
suggestion regarding my second question, i.e., a good
online VBA reference?

Jeff

Quote:
>-----Original Message-----
>Hi Jeff,

>Try the following instead:

>With Selection
>    .HomeKey unit:=wdStory
>    With .Find
>        .ClearFormatting
>        .Text = "Step Name"
>        .Replacement.Text = ""
>        .Forward = True
>        .Wrap = wdFindContinue
>        .Format = False
>        .MatchCase = True
>        .MatchWholeWord = False
>        .MatchWildcards = False
>        .MatchSoundsLike = False
>        .MatchAllWordForms = False
>        ' while it can find each new instance of
>        ' "Step Name"
>        Do While .Execute
>            With Selection
>                With .Tables(1).Columns(1)
>                    .PreferredWidthType =

wdPreferredWidthPoints
Quote:
>                    .PreferredWidth = InchesToPoints(0.6)
>                End With
>                .Move unit:=wdColumn, Count:=1
>                .SelectColumn
>                With .Columns
>                    .PreferredWidthType =

wdPreferredWidthPoints
Quote:
>                    .PreferredWidth = InchesToPoints(4.7)
>                End With
>                .Move unit:=wdColumn, Count:=1
>                .SelectColumn
>                With .Columns
>                    .PreferredWidthType =

wdPreferredWidthPoints

- Show quoted text -

Quote:
>                    .PreferredWidth = InchesToPoints(4.7)
>                End With
>                .MoveDown unit:=wdLine, Count:=1
>            End With
>Loop
>    End With
>End With

>HTH


>> It isn't pretty, but the entire macro that I run in Word
>> is below.

>> Jeff

>> Sub ResizeAllTablesInDocument()
>> '
>> ' ResizeAllTablesInDocument Macro
>> ' Macro recorded 11/18/2002 by Jeff Rupprecht
>> ' Search for tables with Step Name as first column name.
>> ' Then resize the table and go on to the next table,
until
>> end of file.
>> '
>> Do While True = True ' Basically, loop until "If"
>> statement ends loop.
>> Selection.Find.ClearFormatting
>>     With Selection.Find
>>         .Text = "Step Name"
>>         .Replacement.Text = ""
>>         .Forward = True
>>         .Wrap = wdFindContinue
>>         .Format = False
>>         .MatchCase = True
>>         .MatchWholeWord = False
>>         .MatchWildcards = False
>>         .MatchSoundsLike = False
>>         .MatchAllWordForms = False
>>     End With
>>     Selection.Find.Execute
>> ' If table column "Step Name" not found
>>     If Selection.Find.Found = False Then
>>         Exit Do    ' Exit loop.
>>     End If
>> ' If table column "Step Name" found
>>     Selection.Tables(1).Columns(1).PreferredWidthType =
>> wdPreferredWidthPoints
>>     Selection.Tables(1).Columns(1).PreferredWidth =
>> InchesToPoints(0.6)
>>     Selection.Move Unit:=wdColumn, Count:=1
>>     Selection.SelectColumn
>>     Selection.Columns.PreferredWidthType =
>> wdPreferredWidthPoints
>>     Selection.Columns.PreferredWidth = InchesToPoints
(4.7)
>>     Selection.Move Unit:=wdColumn, Count:=1
>>     Selection.SelectColumn
>>     Selection.Columns.PreferredWidthType =
>> wdPreferredWidthPoints
>>     Selection.Columns.PreferredWidth = InchesToPoints
(4.7)
>>     Selection.MoveDown Unit:=wdLine, Count:=1
>> Loop
>> End Sub
>> >-----Original Message-----
>> >Hi Jeff,

>> >AFAIK, wdFindContinue will not put you into an infinite
>> loop all by itself.
>> >I suspect there's something else in your routine that
>> causes the loop. Can
>> >you share the revelant portion of your routine?



>> >> 1) For a Selection.Find, what can I set the Wrap
option
>> to
>> >> in order to make the search stop when it reaches the
end
>> >> of file. I get into an infinite loop. My current Wrap
>> >> option is set to wdFindContinue, which I think is the
>> >> problem. But I don't know the other values I can set
it
>> to.

>> >> 2) Is there an online VBA reference where I can find
>> such
>> >> information? For some reason, when I use my company's
>> >> networked MS Word, and I go to Microsoft Visual Basic
>> >> Help, I can go to the Contents tab, but when I try
to go
>> >> to the Index or Answer Wizard tab, I get a
horizontal,
>> >> double-headed arrow and cannot type text into the
field.

>> >> Jeff

>> >.

>.



Sat, 07 May 2005 01:58:30 GMT  
 selection.find wrap options
Hi Jeff,

I'd first recommend that you bookmark the Word MVP site
(http://www.mvps.org/word/) and frequent that as often as possible. Second,
get a book: I really like Steve Roman's Writer Word Macros (although it was
difficult at first and now I think I don't reference it any longer). As for
your particular problem (the help doesn't allow you to enter text), I
encountered this, too. To fix it, I close the current help system, press
CTRL+ALT+DEL and click Task Manager. On the Processes tab, I find
MSOHELP.EXE in the list and End that process. Then, I reaccess the help
without problem. You might give it a whirl.

HTH


Quote:
> Dave,

> Thanks a lot. Your program structure was much more elegant
> than mine. And it worked great. Would you happen to have a
> suggestion regarding my second question, i.e., a good
> online VBA reference?

> Jeff
> >-----Original Message-----
> >Hi Jeff,

> >Try the following instead:

> >With Selection
> >    .HomeKey unit:=wdStory
> >    With .Find
> >        .ClearFormatting
> >        .Text = "Step Name"
> >        .Replacement.Text = ""
> >        .Forward = True
> >        .Wrap = wdFindContinue
> >        .Format = False
> >        .MatchCase = True
> >        .MatchWholeWord = False
> >        .MatchWildcards = False
> >        .MatchSoundsLike = False
> >        .MatchAllWordForms = False
> >        ' while it can find each new instance of
> >        ' "Step Name"
> >        Do While .Execute
> >            With Selection
> >                With .Tables(1).Columns(1)
> >                    .PreferredWidthType =
> wdPreferredWidthPoints
> >                    .PreferredWidth = InchesToPoints(0.6)
> >                End With
> >                .Move unit:=wdColumn, Count:=1
> >                .SelectColumn
> >                With .Columns
> >                    .PreferredWidthType =
> wdPreferredWidthPoints
> >                    .PreferredWidth = InchesToPoints(4.7)
> >                End With
> >                .Move unit:=wdColumn, Count:=1
> >                .SelectColumn
> >                With .Columns
> >                    .PreferredWidthType =
> wdPreferredWidthPoints
> >                    .PreferredWidth = InchesToPoints(4.7)
> >                End With
> >                .MoveDown unit:=wdLine, Count:=1
> >            End With
> >Loop
> >    End With
> >End With

> >HTH


> >> It isn't pretty, but the entire macro that I run in Word
> >> is below.

> >> Jeff

> >> Sub ResizeAllTablesInDocument()
> >> '
> >> ' ResizeAllTablesInDocument Macro
> >> ' Macro recorded 11/18/2002 by Jeff Rupprecht
> >> ' Search for tables with Step Name as first column name.
> >> ' Then resize the table and go on to the next table,
> until
> >> end of file.
> >> '
> >> Do While True = True ' Basically, loop until "If"
> >> statement ends loop.
> >> Selection.Find.ClearFormatting
> >>     With Selection.Find
> >>         .Text = "Step Name"
> >>         .Replacement.Text = ""
> >>         .Forward = True
> >>         .Wrap = wdFindContinue
> >>         .Format = False
> >>         .MatchCase = True
> >>         .MatchWholeWord = False
> >>         .MatchWildcards = False
> >>         .MatchSoundsLike = False
> >>         .MatchAllWordForms = False
> >>     End With
> >>     Selection.Find.Execute
> >> ' If table column "Step Name" not found
> >>     If Selection.Find.Found = False Then
> >>         Exit Do    ' Exit loop.
> >>     End If
> >> ' If table column "Step Name" found
> >>     Selection.Tables(1).Columns(1).PreferredWidthType =
> >> wdPreferredWidthPoints
> >>     Selection.Tables(1).Columns(1).PreferredWidth =
> >> InchesToPoints(0.6)
> >>     Selection.Move Unit:=wdColumn, Count:=1
> >>     Selection.SelectColumn
> >>     Selection.Columns.PreferredWidthType =
> >> wdPreferredWidthPoints
> >>     Selection.Columns.PreferredWidth = InchesToPoints
> (4.7)
> >>     Selection.Move Unit:=wdColumn, Count:=1
> >>     Selection.SelectColumn
> >>     Selection.Columns.PreferredWidthType =
> >> wdPreferredWidthPoints
> >>     Selection.Columns.PreferredWidth = InchesToPoints
> (4.7)
> >>     Selection.MoveDown Unit:=wdLine, Count:=1
> >> Loop
> >> End Sub
> >> >-----Original Message-----
> >> >Hi Jeff,

> >> >AFAIK, wdFindContinue will not put you into an infinite
> >> loop all by itself.
> >> >I suspect there's something else in your routine that
> >> causes the loop. Can
> >> >you share the revelant portion of your routine?



> >> >> 1) For a Selection.Find, what can I set the Wrap
> option
> >> to
> >> >> in order to make the search stop when it reaches the
> end
> >> >> of file. I get into an infinite loop. My current Wrap
> >> >> option is set to wdFindContinue, which I think is the
> >> >> problem. But I don't know the other values I can set
> it
> >> to.

> >> >> 2) Is there an online VBA reference where I can find
> >> such
> >> >> information? For some reason, when I use my company's
> >> >> networked MS Word, and I go to Microsoft Visual Basic
> >> >> Help, I can go to the Contents tab, but when I try
> to go
> >> >> to the Index or Answer Wizard tab, I get a
> horizontal,
> >> >> double-headed arrow and cannot type text into the
> field.

> >> >> Jeff

> >> >.

> >.



Sat, 07 May 2005 02:42:41 GMT  
 selection.find wrap options
It isn't pretty, but the entire macro that I run in Word
is below.

Jeff

Sub ResizeAllTablesInDocument()
'
' ResizeAllTablesInDocument Macro
' Macro recorded 11/18/2002 by Jeff Rupprecht
' Search for tables with Step Name as first column name.
' Then resize the table and go on to the next table, until
end of file.
'
Do While True = True ' Basically, loop until "If"
statement ends loop.
Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "Step Name"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
' If table column "Step Name" not found
    If Selection.Find.Found = False Then
        Exit Do    ' Exit loop.
    End If
' If table column "Step Name" found
    Selection.Tables(1).Columns(1).PreferredWidthType =
wdPreferredWidthPoints
    Selection.Tables(1).Columns(1).PreferredWidth =
InchesToPoints(0.6)
    Selection.Move Unit:=wdColumn, Count:=1
    Selection.SelectColumn
    Selection.Columns.PreferredWidthType =
wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(4.7)
    Selection.Move Unit:=wdColumn, Count:=1
    Selection.SelectColumn
    Selection.Columns.PreferredWidthType =
wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(4.7)
    Selection.MoveDown Unit:=wdLine, Count:=1
Loop
End Sub

Quote:
>-----Original Message-----
>Hi Jeff,

>AFAIK, wdFindContinue will not put you into an infinite
loop all by itself.
>I suspect there's something else in your routine that

causes the loop. Can
Quote:
>you share the revelant portion of your routine?



>> 1) For a Selection.Find, what can I set the Wrap option
to
>> in order to make the search stop when it reaches the end
>> of file. I get into an infinite loop. My current Wrap
>> option is set to wdFindContinue, which I think is the
>> problem. But I don't know the other values I can set it
to.

>> 2) Is there an online VBA reference where I can find
such
>> information? For some reason, when I use my company's
>> networked MS Word, and I go to Microsoft Visual Basic
>> Help, I can go to the Contents tab, but when I try to go
>> to the Index or Answer Wizard tab, I get a horizontal,
>> double-headed arrow and cannot type text into the field.

>> Jeff

>.



Sat, 07 May 2005 01:13:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. range.find fatal vs OK selection.find

2. keeping the Selection.Find.Found property

3. Selection.Find.Execute does not find the text 2nd time thru the loop

4. Option buttons - using vba to determine selection - Help

5. option button selection

6. Option box selection within a frame

7. Setting selection options value in Javascript - Help...

8. Dynamically removing selection options for pull down list

9. Finding multi-line paragraphs (wrapped lines)

10. Need macro to find lines that wrap

11. I must find 5 copies of MS PDS 7.1 (QBX) (preferably shrink-wrapped)

12. DBGrid text wrap - won't stay wrapped!

 

 
Powered by phpBB® Forum Software