Vba word find wrap

title keywords f1_keywords ms.prod api_name ms.assetid ms.date ms.localizationpriority

Find.Wrap property (Word)

vbawd10.chm162529307

vbawd10.chm162529307

word

Word.Find.Wrap

2d6823f3-93aa-383c-af28-d44e6a8a83e2

06/08/2017

medium

Find.Wrap property (Word)

Returns or sets what happens if the search begins at a point other than the beginning of the document and the end of the document is reached (or vice versa if Forward is set to False) or if the search text isn’t found in the specified selection or range. Read/write WdFindWrap.

Syntax

expression. Wrap

expression Required. A variable that represents a ‘Find’ object.

Example

The following example searches forward through the document for the word «aspirin.» When the end of the document is reached, the search continues at the beginning of the document. If the word «aspirin» is found, it is selected.

Sub WordFind() 
 With Selection.Find 
 .Forward = True 
 .ClearFormatting 
 .MatchWholeWord = True 
 .MatchCase = False 
 .Wrap = wdFindContinue 
 .Execute FindText:="aspirin" 
 End With 
End Sub

See also

Find Object

[!includeSupport and feedback]

1508 / 478 / 56

Регистрация: 10.04.2009

Сообщений: 8,008

1

05.02.2011, 09:07. Показов 8786. Ответов 8


Студворк — интернет-сервис помощи студентам

свойство Wrap — поворачивать, заворачивать — определяет поведение поиска при достижении конца документа
Вариантов значения свойства Wrap — всего три
‘wdFindContinue — поиск продолжать — при достижении конца документа поиск будет продолжаться с начала пока не будет достигнуто положение начала поиска
‘wdFindStop — поиск остановить — остановит поиск по достижении конца
Подскажите третье значение и его предназначение



0



Busine2009

Заблокирован

05.02.2011, 10:15

2

Visual Basic
1
.Find.Wrap = wdFindAsk

при достижении конца документа появляется диалоговое окно и предоставляется выбор: остановить поиск с начала документа или провести поиск с начала документа до места, откуда был начат поиск.



0



Ципихович Эндрю

1508 / 478 / 56

Регистрация: 10.04.2009

Сообщений: 8,008

05.02.2011, 11:36

 [ТС]

3

не пойму с Find вроде всё учёл в цикле = 3 из поска слов два раза ищет правильно, что оно одно слово, Счётчк=1, а при последнем проходе цикла указывает, что Счётчик=2, хотя рельно должен быть =1
Делаю так, что не верно??

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
With WordApp.Selection.Find
    .Text = "<" & LCase_Trim_Обрабатываемое & "," 'поиск в начале слова, о чём свидетельствует специальный знак - "<"
    'ClearFormatting - позволяет очистить, убрать все ранее определенные для проведения поиска параметры форматирования
    .ClearFormatting
    'свойство Wrap - поворачивать, заворачивать, определяет поведение поиска при достижении конца документа
    'wdFindContinue - поиск продолжать, при достижении конца документа поиск будет продолжаться с начала пока не будет достигнуто положение начала поиска
    'wdFindStop - поиск остановить, остановит поиск по достижении конца
    'wdFindAsk - при достижении конца документа появляется диалоговое окно, предоставляется выбор: остановить поиск с начала документа или провести поиск с начала документа до места, откуда был начат поиск
    .Wrap = wdFindContinue
    'свойство MatchWildcards отвечает за поиск с использованием подстановочных знаков
    'по умолчанию = False, не работает когда установлено в положение False, или её нет вообще
    'если установлена в положение True, тогда работает и идёт поиск с использованием подстановочных знаков
    .MatchWildcards = True
    'свойство MatchCase заставляет искать слово, соблюдая его регистр, по умолчанию = False
    '.MatchCase = True
    Счётчик = 0
    Do While .Execute = True
       .Parent.Select 'выделит искомые слова
       Счётчик = Счётчик + 1
    Loop
End With



0



Busine2009

Заблокирован

05.02.2011, 11:46

4

Ципихович Эндрю,
Selection и Documents вместе не используются.



0



1508 / 478 / 56

Регистрация: 10.04.2009

Сообщений: 8,008

05.02.2011, 11:50

 [ТС]

5

Selection и Documents вместе не используются — два раза нормально используются
скажу Вам по секрету свой следующий вопрос
Скажите, а как же праввильно???????



0



Busine2009

Заблокирован

05.02.2011, 11:56

6

Ципихович Эндрю,
надо Find использовать или в отношении документа или в отношении Selection.



0



1508 / 478 / 56

Регистрация: 10.04.2009

Сообщений: 8,008

05.02.2011, 12:01

 [ТС]

7

так With WordApp.Find — нельзя указать, тогда решать из соседнего топика вопрос



0



Busine2009

Заблокирован

05.02.2011, 12:03

8

Ципихович Эндрю,
чтобы находить в документе, нужно использовать .Range или .Content.



0



1508 / 478 / 56

Регистрация: 10.04.2009

Сообщений: 8,008

05.02.2011, 12:22

 [ТС]

9

помоему я пробовал
With WordApp.Range.Find
и
With WordApp.Content.Find
ошибки возникали



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

05.02.2011, 12:22

Помогаю со студенческими работами здесь

wrap панель
Как можно сделать wrap панель?

есть 10 div. нужно в стиле или где то задается 2 на 5.

И…

Excel text wrap
Здравствуйте!
Есть &quot;шаблон&quot; репората в Excel, использую Spreadsheet::ParseExcel::SaveParser, все…

ByteBuffer wrap vs put
В чем отличие методов put и wrap ? Я почитал оракловскую документацию, но плохо понял этот вопрос

Querybuilder select wrap in from
Возможно кто-то сталкивался, или понимает как сделать тоже самое через query builder

SELECT…

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

9

Word VBA Find

This example is a simple word macro find the text “a”:

Sub SimpleFind()

    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "a"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
End Sub

Find and Replace

This simple macro will search for the word “their” and replace it with “there”:

Sub SimpleReplace()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "their"
        .Replacement.Text = "there"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Find and Replace Only in Selection

This VBA macro will find and replace text in a selection. It will also italicize the replaced text.

Sub ReplaceInSelection()
'replaces text JUST in selection . in adittion it makes replaced text italic
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "their"

        With .Replacement
            .Font.Italic = True
            .Text = "there"
        End With

        .Forward = True
        .Wrap = wdFindStop    'this prevents Word from continuing to the end of doc
        .Format = True 'we want to replace formatting of text as well
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

This line of code prevents VBA from continuing to the end of the Word document:

.Wrap = wdFindStop    'this prevents Word from continuing to the end of doc

This line of code indicates to replace the formatting of the text as well:

.Format = True 'we want to replace formatting of text as well

Find and Replace Only In Range

Instead of replacing text throughout the entire document, or in a selection, we can tell VBA to find and replace only in range.  In this example we defined the range as the first paragraph:

Dim oRange As Range
Set oRange = ActiveDocument.Paragraphs(1).Range
Sub ReplaceInRange()
'replaces text JUST in range [in this example just in the first paragraph]
Dim oRange As Range
Set oRange = ActiveDocument.Paragraphs(1).Range
 oRange.Find.ClearFormatting
    oRange.Find.Replacement.ClearFormatting
    With oRange.Find
        .Text = "their"
        .Replacement.Text = "there"
        .Forward = True
        .Wrap = wdFindStop 'this prevent Word to continue to the end of doc
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    oRange.Find.Execute Replace:=wdReplaceAll
End Sub

01-13-2009, 09:23 AM


#1

Solved: ActiveDocument.Range.Find options

Can someone please help me understand some off the options available with the .Find command, and some problems that I am having?

First off,

[VBA]
MyRange.Find.Wrap = wdFindContinue / wdFindStop
MyRange.Find.Forward = True / False
[/VBA]
Despite reading Microsofts excellent online documentation (try not to laugh) I am still unclear which of the above options I should using, when I should be using them, and what the differences are.

With the code below, the above options don’t seem to make any difference when finding and replacing text.

[VBA]
Set MyRange = ActiveDocument.Range
MyRange.Find.Text = «test»
MyRange.Replacement.Text = «replaced»
MyRange.Wrap = wdFindStop
MyRange.Forward = True
MyRange.Find.Execute Replace:=wdReplaceAll
[/VBA]

Secondly:

Why doesnt the code below work — is it something to do with the Range being redefined when the highlighting is being cleared?

[VBA]
Private Sub CommandButton1_Click()
Set MyRange = ActiveDocument.Range

‘ Clear highlighting between ‘[‘ and ‘]’ characters
MyRange.Find.Text = «[*]»
MyRange.Find.Wrap = wdFindStop
MyRange.Find.MatchWildcards = True
Do While MyRange.Find.Execute = True
MyRange.HighlightColorIndex = 0 ‘Clear highlighting
Loop

‘ Delete all ‘[‘ characters
MyRange.Find.Text = «[«
MyRange.Find.Replacement.Text = «»
MyRange.Find.MatchWildcards = False
MyRange.Find.Execute Replace:=wdReplaceAll

‘ Delete all ‘]’ characters
MyRange.Find.Text = «]»
MyRange.Find.Execute Replace:=wdReplaceAll
End Sub
[/VBA]

Thirdly:

Is there a vba help file anywhere with Word 2003 ?

And finally:

Can anyone recommend a good book on Word vba.

Kind regards in advance,
Mike.

Edit Lucas: VBA tags added to code. Select your code when posting and hit the vba button to format it for the forum.


01-13-2009, 10:00 AM


#2

You can search this forum. I usually try to help with this but I’m short on time. You can do it though…..

Steve
«Nearly all men can stand adversity, but if you want to test a man’s character, give him power.»
-Abraham Lincoln


Понравилась статья? Поделить с друзьями:
  • Vba word find and replace all
  • Vba word find all text
  • Vba word delete rows
  • Vba word copy from excel
  • Vba word copy documents