<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6850&amp;type=atom" />
	<updated>2012-02-24T12:48:02Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6850</id>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=57185#p57185" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Brainiacs]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27620</uri>
			</author>
			<updated>2012-02-24T12:48:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=57185#p57185</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=57144#p57144" />
			<content type="html"><![CDATA[<p>Это «тот самый вопрос». Автор утверждает, что такой присоединённый шаблон в некоторых документах есть, однако же по выполнению скрипта этого нигде не видно.</p><p>Пока договорились на то, что он выполнит (другим скриптом) опрос нескольких документов на предмет вывода имени присоединённого шаблона (где он <em>заведомо</em> присутствует) и выложит результаты. Так что — пока жду.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2012-02-22T04:34:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=57144#p57144</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=57141#p57141" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Rom5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5724</uri>
			</author>
			<updated>2012-02-21T20:26:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=57141#p57141</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=57138#p57138" />
			<content type="html"><![CDATA[<p><strong>Brainiacs</strong>, укажите в названии темы язык скриптов согласно правилам форума.</p>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2012-02-21T19:33:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=57138#p57138</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[WSH: Удалить путь к шаблон или заменить на шаблон по умолчанию]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=57130#p57130" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Brainiacs]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27620</uri>
			</author>
			<updated>2012-02-21T05:57:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=57130#p57130</id>
		</entry>
</feed>
