<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Как запустить VBA через VBS?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9253&amp;type=atom" />
	<updated>2014-02-12T11:49:02Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9253</id>
		<entry>
			<title type="html"><![CDATA[VBS: Как запустить VBA через VBS?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80011#p80011" />
			<content type="html"><![CDATA[<p>Здравствуйте. ничего не понимаю в VB<br />потому обращаюсь на форумы.</p><p>есть папка с файлами rtf<br />надо удалить первую страницу (не учитывая колонтитулы) если там есть определенное слово.</p><p>на одном форуме помогли и написали на vba макрос по удалению, работает и даже сносит это слово в колонтитулах.<br /></p><div class="codebox"><pre><code>Sub makr()
Dim s1, j1, j2, s2, s3
Dim obj As Object
Dim zm1, zm2
zm1 = &quot;keyword&quot;
zm2 = &quot;.keyword.&quot;
Dim tbl As Table
&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;
s1 = Word.ActiveDocument.Sections(1).Range.Text
If InStr(s1, zm1) &gt; 0 Then
Debug.Print &quot;1ok&quot;
Word.ActiveDocument.Sections(1).Range.Delete
End If
&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;
j1 = Word.ActiveDocument.Sections(1).Headers.Count
Do While j1 &gt; 0
Word.ActiveDocument.Sections(1).Headers(j1).Range.Select
If Selection.Tables.Count &gt; 0 Then
Set tbl = Selection.Tables(1)
j2 = tbl.Range.Cells.Count
Do While j2 &gt; 0
s1 = tbl.Range.Cells(j2).Range.Text
Debug.Print j1, j2, s1;
If InStr(s1, zm1) &gt; 0 Or InStr(s1, zm2) &gt; 0 Then
Debug.Print &quot;**&quot;
tbl.Range.Cells(j2).Range.Text = &quot;&quot;
End If
j2 = j2 - 1
Loop
End If
j1 = j1 - 1
Loop
&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;
j1 = Word.ActiveDocument.Sections(1).Footers.Count
Do While j1 &gt; 0
Word.ActiveDocument.Sections(1).Footers(j1).Range.Select
If Selection.Tables.Count &gt; 0 Then
Set tbl = Selection.Tables(1)
j2 = tbl.Range.Cells.Count
Do While j2 &gt; 0
s1 = tbl.Range.Cells(j2).Range.Text
Debug.Print j1, j2, s1;
If InStr(s1, zm1) &gt; 0 Or InStr(s1, zm2) &gt; 0 Then
Debug.Print &quot;**&quot;
tbl.Range.Cells(j2).Range.Text = &quot;&quot;
End If
j2 = j2 - 1
Loop
End If
j1 = j1 - 1
Loop
  &#039;ActiveWindow.ActivePane.View.Type = wdPrintView
  ActiveWindow.View.Type = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
 Selection.WholeStory
End Sub
</code></pre></div><p>еще нашел скрипт на VBS, который открывает файлы из папок и удаляет все ссылки.<br /></p><div class="codebox"><pre><code>With CreateObject(&quot;word.application&quot;)
  For Each x In CreateObject(&quot;scripting.filesystemobject&quot;).getfile(wscript.scriptfullname).parentfolder.Files
    If LCase(Mid(x.Name, InStrRev(x.Name, &quot;.&quot;) + 1, 4)) = &quot;rtf&quot; Then
      With .documents.open(x.Path)
        numDocs = numDocs + 1
        .Range.Fields.Unlink &#039;Ctrl+A, Ctrl+Shift+F9
        .Close True &#039;save changes
      End With
    End If
  Next
  .Quit
End With
wscript.echo &quot;Обработано документов &quot; &amp; numDocs</code></pre></div><p>Вот вопрос как их соединить, чтобы при запуске VBS файла применялся макрос по удалению первой страницы?</p><p>в общем уже не актуально, решил задачу другим способом</p>]]></content>
			<author>
				<name><![CDATA[Alex]]></name>
			</author>
			<updated>2014-02-12T11:49:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80011#p80011</id>
		</entry>
</feed>
