<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6850</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6850&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию».]]></description>
		<lastBuildDate>Fri, 24 Feb 2012 12:48:02 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57185#p57185</link>
			<description><![CDATA[<p>Большущее спасибо to <strong>Petya V4sechkin и alexii aka Iska aka хорошие люди)))</strong></p><p>Публикую рабочий скриптик!!!</p><div class="codebox"><pre><code>Option Explicit

Const wdDialogToolsTemplates = &amp;H57

Dim strDocumentList
Dim strBadTemplate
Dim strDocument
Dim strTemplate

Dim objFSO
Dim objWord


strDocumentList = &quot;E:\Песочница\0120\DocumentList.txt&quot;
strBadTemplate  = &quot;\\fileserver2\USERS$\sba\My Documents\Brand Manual\Brand Manual\templates Norit russia\Templates NV\Norit NV - brief - ENG, V060403.dot&quot;


Set objFSO = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)

If objFSO.FileExists(strDocumentList) Then
    Set objWord = WScript.CreateObject(&quot;Word.Application&quot;)
    
    With objFSO.OpenTextFile(strDocumentList)
        Do Until .AtEndOfStream
            strDocument = .ReadLine()
            
            If objFSO.FileExists(strDocument) Then
                WScript.Echo strDocument
                
                With objWord.Documents.Open(strDocument)
                    strTemplate = objWord.Dialogs(wdDialogToolsTemplates).Template
                    
                    If strTemplate = strBadTemplate Then
                        WScript.Echo &quot;  Template found in document [&quot; &amp; strDocument &amp; &quot;]&quot;
                        
                        .AttachedTemplate = &quot;Normal.dotm&quot;
                        .Save
                    End If
                    
                    .Close
                End With
            Else
                WScript.Echo &quot;Document [&quot; &amp; strDocument &amp; &quot;] not found&quot;
            End If
        Loop
        
        .Close
    End With
    
    objWord.Quit
    
    Set objWord = Nothing
Else
    WScript.Echo &quot;Document list [&quot; &amp; strDocumentList &amp; &quot;] not found&quot;
End If

Set objFSO = Nothing

WScript.Quit 0</code></pre></div><p><strong>With Best Regards<br />Brainiacs</strong></p>]]></description>
			<author><![CDATA[null@example.com (Brainiacs)]]></author>
			<pubDate>Fri, 24 Feb 2012 12:48:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57185#p57185</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57144#p57144</link>
			<description><![CDATA[<p>Это «тот самый вопрос». Автор утверждает, что такой присоединённый шаблон в некоторых документах есть, однако же по выполнению скрипта этого нигде не видно.</p><p>Пока договорились на то, что он выполнит (другим скриптом) опрос нескольких документов на предмет вывода имени присоединённого шаблона (где он <em>заведомо</em> присутствует) и выложит результаты. Так что — пока жду.</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Wed, 22 Feb 2012 04:34:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57144#p57144</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57141#p57141</link>
			<description><![CDATA[<p>А сообщение после сравнения по команде:<br /></p><div class="codebox"><pre><code>
If .AttachedTemplate = strBadTemplate Then
WScript.Echo &quot;  Template found in document [&quot; &amp; strDocument &amp; &quot;]&quot;</code></pre></div><p>выводится или нет?</p>]]></description>
			<author><![CDATA[null@example.com (Rom5)]]></author>
			<pubDate>Tue, 21 Feb 2012 20:26:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57141#p57141</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57138#p57138</link>
			<description><![CDATA[<p><strong>Brainiacs</strong>, укажите в названии темы язык скриптов согласно правилам форума.</p>]]></description>
			<author><![CDATA[null@example.com (JSmаn)]]></author>
			<pubDate>Tue, 21 Feb 2012 19:33:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57138#p57138</guid>
		</item>
		<item>
			<title><![CDATA[WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57130#p57130</link>
			<description><![CDATA[<p>Доброго времени!</p><p>А помогите доработать скриптик (не мои):</p><div class="codebox"><pre><code>Option Explicit

Dim strDocumentList
Dim strBadTemplate
Dim strDocument

Dim objFSO
Dim objWord


strDocumentList = &quot;E:\Песочница\0116\DocumentList.txt&quot;
strBadTemplate  = &quot;\\fileserver2\USERS$\sba\My Documents\Brand Manual\Brand Manual\templates Norit russia\Templates NV\Norit NV - brief - ENG, V060403.dot&quot;


Set objFSO = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)

If objFSO.FileExists(strDocumentList) Then
    Set objWord = WScript.CreateObject(&quot;Word.Application&quot;)
    
    With objFSO.OpenTextFile(strDocumentList)
        Do Until .AtEndOfStream
            strDocument = .ReadLine()
            
            If objFSO.FileExists(strDocument) Then
                WScript.Echo strDocument
                
                With objWord.Documents.Open(strDocument)
                    If .AttachedTemplate = strBadTemplate Then
                        WScript.Echo &quot;  Template found in document [&quot; &amp; strDocument &amp; &quot;]&quot;
                        
                        .AttachedTemplate = &quot;Normal.dotm&quot;
                        .Save
                    End If
                    
                    .Close
                End With
            Else
                WScript.Echo &quot;Document [&quot; &amp; strDocument &amp; &quot;] not found&quot;
            End If
        Loop
        
        .Close
    End With
    
    objWord.Quit
    
    Set objWord = Nothing
Else
    WScript.Echo &quot;Document list [&quot; &amp; strDocumentList &amp; &quot;] not found&quot;
End If

Set objFSO = Nothing

WScript.Quit 0</code></pre></div><div class="codebox"><pre><code>strDocumentList = &quot;E:\Песочница\0116\DocumentList.txt&quot;</code></pre></div><p>в этом файлике список путей к файлам ворд, созданный TotalCommander&#039;ом:</p><div class="codebox"><pre><code>.........
Z:\CDM\anketa_k.doc
Z:\CDM\pravil_karta_scheta.doc
..............</code></pre></div><div class="codebox"><pre><code>strBadTemplate</code></pre></div><p>это шаблон который встроен в вордовские документы (таких доков много)</p><p>Задача: удалить путь к шаблон или заменить на шаблон по умолчанию (в 1283 документах)</p><p>Не работает, что-то скриптик! Файл он открывает, но шаблон не удаляет и не заменяет!</p><div class="codebox"><pre><code>.AttachedTemplate =</code></pre></div><p>Пробовал подставлять и пробел и просто пустым оставлять, и полный путь&nbsp; к Normal.dotm - не работает!</p><p><strong>With Best Regards<br />Brainiacs</strong></p>]]></description>
			<author><![CDATA[null@example.com (Brainiacs)]]></author>
			<pubDate>Tue, 21 Feb 2012 05:57:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57130#p57130</guid>
		</item>
	</channel>
</rss>
