<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS: вставить строку из .doc в .txt]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=10076</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10076&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS: вставить строку из .doc в .txt».]]></description>
		<lastBuildDate>Tue, 28 Oct 2014 11:04:26 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87815#p87815</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Только убрал лишние пробелы (не очень красиво выходило).</p></blockquote></div><p>В конце «красной» строки? Внутри?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Tue, 28 Oct 2014 11:04:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87815#p87815</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87814#p87814</link>
			<description><![CDATA[<p>Большое спасибо! Получилось то, что хотел! Только убрал лишние пробелы (не очень красиво выходило).</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Tue, 28 Oct 2014 10:37:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87814#p87814</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87809#p87809</link>
			<description><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p>&nbsp; В общем, я выбрал второй вариант.</p></blockquote></div><p>Я это и имел ввиду. Спасибо. Буду пробовать.</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Tue, 28 Oct 2014 04:49:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87809#p87809</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87804#p87804</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>1. Вставлятся в текстовый файл должна выкрашеная строка.</p></blockquote></div><p>Опять обошли ответ. На что ориентируемся со слова «от …» — на 40 символов или, не считая — до конца строки? В общем, я выбрал второй вариант.</p><p>Пробуйте:<br /></p><div class="codebox"><pre><code>Option Explicit

Const wdFindContinue = 1

Const wdParagraph = 4
Const wdCharacter = 1
Const wdExtend = 1


Dim strSourceFile
Dim strDestFile

Dim strSorceFilePattern
Dim strDestFilePhrase


Dim strText
Dim strContent

Dim boolFound


strSourceFile = &quot;E:\Песочница\0404\test\Список.doc&quot;
strDestFile   = &quot;E:\Песочница\0404\test\Test22.txt&quot;

strSorceFilePattern = &quot;от [0-9]{2}.[0-9]{2}.[0-9]{4} @№&quot;
strDestFilePhrase   = &quot;Auto File Transfer&quot;


With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    If .FileExists(strSourceFile) Then
        If .FileExists(strDestFile) Then
            boolFound = False
            
            With WScript.CreateObject(&quot;Word.Application&quot;)
                &#039;.Visible = True
                
                With .Documents.Open(strSourceFile)
                    With .Content.Find
                        .ClearFormatting
                        .Text = strSorceFilePattern
                        
                        .Forward = True
                        .Wrap = wdFindContinue
                        
                        .Format = False
                        .MatchCase = False
                        .MatchWholeWord = False
                        .MatchAllWordForms = False
                        .MatchSoundsLike = False
                        .MatchWildcards = True
                        
                        With .Replacement
                            .Text = &quot;&quot;
                            .ClearFormatting
                        End With
                        
                        If .Execute() Then
                            With .Parent
                                .EndOf wdParagraph, wdExtend
                                .MoveEnd wdCharacter, -1
                                strText = .Text
                            End With
                            
                            boolFound = True
                        End If
                    End With
                    
                    .Close
                End With
                
                .Quit
            End With
            
            If boolFound Then
                With .OpenTextFile(strDestFile)
                    strContent = .ReadAll()
                    .Close
                End With
                
                If InStr(1, strContent, strDestFilePhrase, vbTextCompare) &gt; 0 Then
                    With .CreateTextFile(strDestFile, True)
                        .Write Replace(strContent, strDestFilePhrase, strText)
                        .Close
                    End With
                Else
                    WScript.Echo &quot;Can&#039;t find phrase [&quot; &amp; strDestFilePhrase &amp; &quot;] in destination file [&quot; &amp; strDestFile &amp; &quot;].&quot;
                    WScript.Quit 4
                End If
            Else
                WScript.Echo &quot;Can&#039;t find any text by pattern [&quot; &amp; strSorceFilePattern &amp; &quot;] in source file [&quot; &amp; strSourceFile &amp; &quot;].&quot;
                WScript.Quit 3
            End If
        Else
            WScript.Echo &quot;Can&#039;t find destination file [&quot; &amp; strDestFile &amp; &quot;].&quot;
            WScript.Quit 2
        End If
    Else
        WScript.Echo &quot;Can&#039;t find source file [&quot; &amp; strSourceFile &amp; &quot;].&quot;
        WScript.Quit 1
    End If
End With

WScript.Quit 0
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Mon, 27 Oct 2014 22:45:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87804#p87804</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87778#p87778</link>
			<description><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p><strong>siv14</strong>, потерпите ещё немного. В процессе.</p><p>... но строка выкрашена в красный до конца абзаца. Может, на это ориентироваться?</p></blockquote></div><p>Добрый день!<br />Теперь все по-порядку:<br />1. Вставлятся в текстовый файл должна выкрашеная строка.<br />2. Вставляться выкрашеная строка должна вместо - Auto File Transfer.<br />3. Ориентироваться можно на номер строки или на текст «Auto File Transfer», они постоянны.<br />4. Место замены определяем по тексту «Auto File Transfer».</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Mon, 27 Oct 2014 13:28:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87778#p87778</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87777#p87777</link>
			<description><![CDATA[<p><strong>siv14</strong>, потерпите ещё немного. В процессе.</p><p>Попутно вопросы: изначально речь шла про «определённое количество символов», далее уточнялось про «40». Из самого приложенного документа количество не ясно, но строка выкрашена в красный до конца абзаца. Может, на это ориентироваться?</p><p>Далее, в приложенном текстовом файле строка «Subject: Auto File Transfer». Вы пишете и «в текстовый документ, в определенную строку», и «в текстовый файл вместо Auto.... надо вставить эти символы». Так на что ориентируемся — на номер строки или на текст «Auto»? Вставляем вместо только «Auto» или вместо «Auto File Transfer»? Опять же, место замены определяем по количеству символов или ориентируемся на текст «Subject: »?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Mon, 27 Oct 2014 10:42:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87777#p87777</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87776#p87776</link>
			<description><![CDATA[<p>Добрый день! <br />Нашел на форуме скрипт поиска строки в текстовом файле. Он подошел к моим условиям, но там где &quot;Вставка из Word&quot;, не пойму что надо сделать. По идее надо найти строку в Word&#039;е, скопировать, присвоить ее переменной и затем вставить в текст. Но каким образом не пойму. Помогите пожалуйста.</p><div class="quotebox"><blockquote><p>Option Explicit</p><p>Dim strSourceFile<br />Dim arrContent<br />Dim strLine</p><br /><p>strSourceFile = &quot;d:\Test22.txt&quot;</p><p>With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)<br />&nbsp; &nbsp; If .FileExists(strSourceFile) Then<br />&nbsp; &nbsp; &nbsp; &nbsp; With .OpenTextFile(strSourceFile)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arrContent = Split(.ReadAll(), vbCrLf)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Close<br />&nbsp; &nbsp; &nbsp; &nbsp; End With<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; With WScript.CreateObject(&quot;VBScript.RegExp&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .IgnoreCase = True<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For Each strLine In arrContent<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Pattern = &quot;^.*(Auto).*$&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If .Test(strLine) Then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WScript.Echo &quot;Вставка из Word&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<br />&nbsp; &nbsp; &nbsp; &nbsp; WScript.Echo &quot;Нет такой строки&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; WScript.Quit 1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next<br />&nbsp; &nbsp; &nbsp; &nbsp; End With<br />&nbsp; &nbsp; Else<br />&nbsp; &nbsp; &nbsp; &nbsp; WScript.Echo &quot;Source file [&quot; &amp; strSourceFile &amp; &quot;] not found.&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; WScript.Quit 1<br />&nbsp; &nbsp; End If<br />End With</p><p>WScript.Quit 0</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Mon, 27 Oct 2014 09:20:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87776#p87776</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87775#p87775</link>
			<description><![CDATA[<p>Вот мой http://rghost.net/58736695 Test.rar</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Mon, 27 Oct 2014 06:34:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87775#p87775</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87774#p87774</link>
			<description><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p>выложите последний на RGhost.</p></blockquote></div><p>У меня не выходит разместить файл в RGhost, поэтому я его приаттачил здесь. Не будет это большой ошибкой?</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Mon, 27 Oct 2014 06:18:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87774#p87774</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87699#p87699</link>
			<description><![CDATA[<p>Количество символов - 40, в текстовый файл вместо Auto.... надо вставить эти символы. Количество строк в .txt постоянно.</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Fri, 24 Oct 2014 10:32:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87699#p87699</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87698#p87698</link>
			<description><![CDATA[<p>Конкретная реализация будет явным образом зависеть от деталей техзадания.</p><p>Упакуйте образцы документа и текстового файла в архив, выложите последний на RGhost. Укажите конкретное значение «определённого количества символов», что это за символы, как они соотносятся с найденной строкой, что делать, если их окажется меньше. Укажите конкретное значение «определённой строки», а также, что делать, если строк в текстовом файле окажется меньше.</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Fri, 24 Oct 2014 09:43:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87698#p87698</guid>
		</item>
		<item>
			<title><![CDATA[VBS: вставить строку из .doc в .txt]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87697#p87697</link>
			<description><![CDATA[<p>Добрый день! Просмотрел форум, но не нашел подходящей темы (или плохо смотрел). Надо найти в документе Word строку (дата № ) и вставить определенное количество символов в текстовый документ, в определенную строку. Как можно решить эту задачу?</p>]]></description>
			<author><![CDATA[null@example.com (siv14)]]></author>
			<pubDate>Fri, 24 Oct 2014 09:28:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87697#p87697</guid>
		</item>
	</channel>
</rss>
