<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBA Word. Selection в защищенной части документа]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=16105&amp;type=atom" />
	<updated>2021-02-19T08:06:28Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=16105</id>
		<entry>
			<title type="html"><![CDATA[VBA Word. Selection в защищенной части документа]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=146337#p146337" />
			<content type="html"><![CDATA[<p>Уважаемые коллеги,<br />Как программно понять, что Selection находится в защищенной части документа.<br />Надо &quot;подрихтовать&quot; нежелательное форматирование для некоторых кусков текста.<br />Начало документа защищено от шаловливых ручек - заполняется программно.<br />&quot;прочесать&quot; надо весь документ, за исключением защищенных участков.<br />Делаю следующее</p><div class="codebox"><pre><code>    Selection.Collapse

	ActiveDocument.UndoClear

    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    With Selection.Find
...
        .Text = &quot;^p&quot;
...
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    While Selection.Find.Execute = True
    On Error GoTo Conti
...
        Selection.Font.Bold = False
        Selection.Font.Size = 12
        Selection.MoveRight Unit:=wdCharacter, Count:=1  &#039;&#039;, Extend:=wdExtend
Conti:
    Wend</code></pre></div><p>Вставил <strong>On Error</strong> , он отрабатывает первый раз, а на следующем найденном фрагменте ломается (видимо, еще активен).<br />ВИжу два решения:<br />1. &quot;понимать, что найденный Selection в защищенной &quot;зоне&quot;<br />2. Как-то подружиться с&nbsp; <strong>On Error</strong><br />Оба варианта мне неведомы<br />Заранее благодарен.</p>]]></content>
			<author>
				<name><![CDATA[Dbeer]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27443</uri>
			</author>
			<updated>2021-02-19T08:06:28Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=146337#p146337</id>
		</entry>
</feed>
