<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: печать документов]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=1275&amp;type=atom" />
	<updated>2009-02-28T14:14:53Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=1275</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: печать документов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=20118#p20118" />
			<content type="html"><![CDATA[<p>Печать файла ассоциированным приложением с помощью объекта <a href="http://forum.script-coding.com/viewtopic.php?pid=20110#p20110">JSSys3.dll</a>:<br /></p><div class="codebox"><pre><code>Set oSys = CreateObject(&quot;JSSys3.Ops&quot;)
errCode = oSys.PrintFile(&quot;C:\Temp\test.odt&quot;)
WScript.Echo errCode &#039;  0 - OK, -1 error, 2 - file not found,
&#039; 3 - path not found, 5 - access denied, 32 - sharing violation</code></pre></div>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2009-02-28T14:14:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=20118#p20118</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: печать документов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=9874#p9874" />
			<content type="html"><![CDATA[<p>Аналогичный пример для MS Excel:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objExcel
Dim objWorkbook

Set objExcel = WScript.CreateObject(&quot;Excel.Application&quot;)

With objExcel
    &#039; .Workbooks.Open(FileName, UpdateLinks, ReadOnly,...)
    &#039;
    &#039;  UpdateLinks is:
    &#039; 0 Doesn&#039;t update any references 
    &#039; 1 Updates external references but not remote references 
    &#039; 2 Updates remote references but not external references 
    &#039; 3 Updates both remote and external references 
    &#039;
    &#039; or .AskToUpdateLinks = False
    &#039; Теоретически возможно появление и других непредусмотренных диалогов
    &#039; Возможно, в этом случае стоит поиграться со свойством Application.DisplayAlerts
    
    Set objWorkbook = .Workbooks.Open(&quot;C:\Temp\01.xls&quot;, 0, True)
    
    objWorkbook.PrintOut
    objWorkbook.Saved = True
    
    Set objWorkbook = Nothing
    
    .Quit
End With

Set objExcel = Nothing

WScript.Quit 0</code></pre></div><p>Автор примера - <strong>alexii</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2008-03-20T14:04:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=9874#p9874</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: печать документов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=9867#p9867" />
			<content type="html"><![CDATA[<p>Усовершенствованный пример от <strong>alexii</strong>:<br /></p><div class="codebox"><pre><code>Option Explicit

Const wdDoNotSaveChanges    =  0
Const wdPromptToSaveChanges = -2
Const wdSaveChanges         = -1


Dim objWord
Dim objDoc

Set objWord = WScript.CreateObject(&quot;Word.Application&quot;)

With objWord
    &#039; .Documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles)
    Set objDoc = .Documents.Open(&quot;C:\Temp\01.doc&quot;, False, True, False)
    
    &#039; 
    &#039;- Метод 1. Печать в фоновом режиме -----------------------------------------
    objDoc.PrintOut True                         &#039; .PrintOut(Background)
    
    &#039; Здесь, при необходимости, можно делать что-то ещё

    Do
        WScript.Sleep 500
    Loop Until .BackgroundPrintingStatus = 0     &#039; Ждём окончания фоновой печати
    &#039;----------------------------------------------------------------------------
    
    &#039;- Метод 2. Печать напрямую -------------------------------------------------
    objDoc.PrintOut False                        &#039; .PrintOut(Background)
    &#039;----------------------------------------------------------------------------
    
    Set objDoc = Nothing
    
    .Quit wdDoNotSaveChanges                     &#039; .Quit(SaveChanges)
End With

Set objWord = Nothing

WScript.Quit 0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2008-03-19T12:51:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=9867#p9867</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: печать документов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=9864#p9864" />
			<content type="html"><![CDATA[<p>Пример распечатывает документ MS Word <em>C:\Temp\test.doc</em> на принтере по умолчанию, никаких окон не отображается.<br /></p><div class="codebox"><pre><code>Dim w
Set W = CreateObject(&quot;Word.Application&quot;)
w.Visible = false
w.Documents.Open &quot;C:\Temp\test.doc&quot;
w.ActiveDocument.PrintOut
WScript.Sleep(1000)
w.Quit
Set w = Nothing</code></pre></div><p>Автор примера - <strong>Alexbootch</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2008-03-19T06:56:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=9864#p9864</id>
		</entry>
</feed>
