<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; WSH: печать документа из IExplorer]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=200</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=200&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «WSH: печать документа из IExplorer».]]></description>
		<lastBuildDate>Wed, 14 Oct 2009 21:15:34 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=29234#p29234</link>
			<description><![CDATA[<p>По <a href="http://forum.oszone.net/post-1236703.html#post1236703">оригинальному сообщению</a> <strong>amel27</strong>:<br /></p><div class="quotebox"><cite>amel27 пишет:</cite><blockquote><div class="quotebox"><cite>Loki3D пишет:</cite><blockquote><p>как можно изменить ориентацию листа с книжной на Альбомную</p></blockquote></div><p>не так просто... учитывая, что IE не сохраняет ориентацию листа, а каждый раз считывает настройки с принтера, кроме того в KB236777 <a href="http://support.microsoft.com/kb/236777/">How to change print settings for Internet Explorer and the WebBrowser control programmatically in Internet Explorer</a> недвусмысленно сказано, что программно эту настройку в IE изменить нельзя:<br /></p><div class="quotebox"><cite>KB236777 пишет:</cite><blockquote><p>There might be a need to change the print settings of Internet Explorer or the WebBrowser control programmatically. The only settings that can be changed are page margins, and header and footer information. There is no supported way to change other settings like page orientation or printer.</p></blockquote></div><p>тем не менее есть один вариант (кроме ручной перенастройки параметров принтера): сходить по этому <em>[KB198901 — alexii]</em> линку: <a href="http://support.microsoft.com/kb/198901">SAMPLE: PageSet.exe Programmatically Changes Default Printer Orientation</a>, скачать оттуда Pageset.exe, выдернуть из комплекта PageSet.dll и зарегистрировать его в системе через RegSvr32 - после этого COM-объект можно использовать в WSH. Слегка измененный VBS-скрипт, использующий функциональность &quot;PageSet.PrinterControl&quot; - перед печатью ориентация устанавливается на книжную, а после - восстанавливается на первоначальную…</p></blockquote></div><p>Здесь я позволил себе слегка вмешаться в код и несколько подправить в более привычный вид, в том числе добавить ожидание завершения печати.<br /></p><div class="codebox"><pre><code>Option Explicit

Const OLECMDID_PRINT              = 6
Const LECMDEXECOPT_DONTPROMPTUSER = 2

Dim objIE
Dim objPrinterControl

Dim boolDone


Set objIE             = WScript.CreateObject(&quot;InternetExplorer.Application&quot;, &quot;IE_&quot;)
Set objPrinterControl = WScript.CreateObject(&quot;PageSet.PrinterControl&quot;)

objPrinterControl.ChngOrientationLandscape
objIE.Navigate &quot;http://www.script-coding.com&quot;

Do
    WScript.Sleep 100
Loop Until Not objIE.Busy

&#039;objIE.Visible = True
objIE.ExecWB OLECMDID_PRINT, LECMDEXECOPT_DONTPROMPTUSER

boolDone = False

Do
    WScript.Sleep 100
Loop Until boolDone

objPrinterControl.ReSetOrientation
objIE.Quit

Set objPrinterControl = Nothing
Set objIE             = Nothing

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
Sub IE_PrintTemplateTeardown(ByVal pDisp)
    boolDone = True
End Sub
&#039;=============================================================================</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Wed, 14 Oct 2009 21:15:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=29234#p29234</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=26705#p26705</link>
			<description><![CDATA[<p>Всем доброго времени суток.<br />Столкнулся с проблемой:<br />Требуется печатать страницы в &quot;Альбомной ориентации&quot;<br />По умолчанию в IE стоит &quot;Книжная&quot;<br />Как скриптом выставить требуемое так и не нашел решения (.</p><p>Из попыток: <br />В реестре, в HKCU есть раздел &quot;Software\Microsoft\Internet Explorer\PageSetup&quot;<br />в нем ключи margin_* всех сторон, как я понял отступы.<br />При изменении из меню IE смежные стороны смещаются наоборот&nbsp; (тоесть меняется страница Книжная-Альбомная ориентации)<br />Изменяя заранее эти значения, страница продолжает печататься в &quot;книжной&quot; ориентации. </p><p>Заранее благодарен за какую либо помощь )</p>]]></description>
			<author><![CDATA[null@example.com (druni@)]]></author>
			<pubDate>Mon, 03 Aug 2009 16:19:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=26705#p26705</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=17631#p17631</link>
			<description><![CDATA[<p>2 The gray Cardinal<br />Человеческое спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (AirKite)]]></author>
			<pubDate>Fri, 26 Dec 2008 21:03:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=17631#p17631</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=17630#p17630</link>
			<description><![CDATA[<p>Конкатенация строк - символ &quot;&amp;&quot;, а не просто пробел.<br /></p><div class="codebox"><pre><code>txtStream.WriteLine &quot;Текст-до-титла&quot; &amp; nodeTitle.text &amp; &quot;текст-после-титла&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Fri, 26 Dec 2008 19:49:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=17630#p17630</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=17625#p17625</link>
			<description><![CDATA[<p>А некто не подскажет, как сделать чтобы в строке дописывался мой текст...<br />Например:<br /></p><div class="codebox"><pre><code>    Set nodeTitle = nodeNode.selectSingleNode(&quot;title&quot;)
    txtStream.WriteLine nodeTitle.text</code></pre></div><p>nodeTitle.text = ТИТЛ-1 (к примеру)</p><p>Как сделать, чтобы было так:<br />Текст-до-титла ТИТЛ-1 текст-после-титла</p><p>Как изменить код?<br />Вот так например не получаеться)))<br /></p><div class="codebox"><pre><code>    Set nodeTitle = nodeNode.selectSingleNode(&quot;title&quot;)
    txtStream.WriteLine &quot;Текст-до-титла&quot; nodeTitle.text &quot;текст-после-титла&quot;</code></pre></div><p>Помогите пожалусто. Я в VBS не разбираюсь!</p>]]></description>
			<author><![CDATA[null@example.com (AirKite)]]></author>
			<pubDate>Fri, 26 Dec 2008 18:06:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=17625#p17625</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=995#p995</link>
			<description><![CDATA[<p><strong>adm_tolik_in</strong><br />Обрати внимание, что я печатаю на принтер по умолчанию, а не на произвольный. Если это проблема, её надо решать дополнительно.<br /></p><div class="codebox"><pre><code>правда так и не понял как удалось на форму печати выйти</code></pre></div><p>Если ты имеешь в виду то окошко, которое открывается при нажатии на ссылку &quot;Печать&quot;, то я просто посмотрел в код HTML-страницы (что она делает при нажатии на ссылку, а там просто кое-какой JavaScript), и сделал &quot;то же самое&quot;. А именно - взял пару переменных, которые при загрузке &quot;основной&quot; страницы уже содержат нужный HTML-код для &quot;страницы печати&quot;, и воспользовался ими (это переменные prhdr и frc). Т.е., если дизайн страницы сильно поменяют, работать это перестанет <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Wed, 01 Nov 2006 13:47:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=995#p995</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=993#p993</link>
			<description><![CDATA[<p>спасибо огромное, это точно как надо. я уже сутки мучаюсь с ней. правда так и не понял как удалось на форму печати выйти.</p>]]></description>
			<author><![CDATA[null@example.com (adm_tolik_in)]]></author>
			<pubDate>Wed, 01 Nov 2006 12:04:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=993#p993</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=986#p986</link>
			<description><![CDATA[<p>Вот, наверное, наиболее подходящий вариант (наиболее близкий к поставленной задаче):<br /></p><div class="codebox"><pre><code>Set objIE = CreateObject(&quot;InternetExplorer.Application&quot;) 
objIE.Navigate &quot;http://www.gismeteo.ru/towns/34723.htm&quot;
While objIE.Busy
    Wscript.Sleep 200
Wend
strHTML = objIE.document.script.prhdr &amp; objIE.document.script.frc &amp; &quot;&lt;/body&gt;&lt;/html&gt;&quot;
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set txtStream = FSO.CreateTextFile(&quot;C:\Temp\weather.htm&quot;)
txtStream.Write(strHTML)
txtStream.Close
objIE.Navigate &quot;C:\Temp\weather.htm&quot;
While objIE.Busy
    Wscript.Sleep 200
Wend
objIE.Visible = 1
For i=1 To 3
    objIE.ExecWB 6, 2 &#039;немедленная печать
    WScript.Sleep 2000
Next
FSO.DeleteFile &quot;C:\Temp\weather.htm&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Tue, 31 Oct 2006 16:12:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=986#p986</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=980#p980</link>
			<description><![CDATA[<p>Ещё вариант:<br /></p><div class="codebox"><pre><code>Set objIE = CreateObject(&quot;InternetExplorer.Application&quot;)
objIE.Navigate &quot;http://pda.gismeteo.ru/e34723.htm&quot;
While objIE.Busy
    Wscript.Sleep 200
Wend
objIE.Visible = 1
&#039;objIE.ExecWB 6, 1 &#039;выдача диалога печати
objIE.ExecWB 6, 2 &#039;немедленная печать</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Mon, 30 Oct 2006 21:14:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=980#p980</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=979#p979</link>
			<description><![CDATA[<p>Вот так можно распечатать погоду из RSS:<br /></p><div class="codebox"><pre><code>Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set txtStream = FSO.CreateTextFile(&quot;C:\Temp\weather.txt&quot;, True)
Set xmlParser = CreateObject(&quot;Msxml2.DOMDocument&quot;)
xmlParser.async = False
xmlParser.load &quot;http://informer.gismeteo.ru/rss/34723.xml&quot;
&#039;получаем все элементы &quot;item&quot;
Set colNodes = xmlParser.selectNodes(&quot;//item&quot;)
For Each nodeNode In colNodes
    &#039;заголовок
    Set nodeTitle = nodeNode.selectSingleNode(&quot;title&quot;)
    txtStream.WriteLine nodeTitle.text
    &#039;содержимое
    Set nodeDescr = nodeNode.selectSingleNode(&quot;description&quot;)
    txtStream.WriteLine nodeDescr.text
    &#039;пустая строка
    txtStream.WriteLine
Next
txtStream.Close
For i=1 To 2
    WshShell.Run &quot;notepad /p C:\Temp\weather.txt&quot;, 0, True
Next
FSO.DeleteFile &quot;C:\Temp\weather.txt&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Mon, 30 Oct 2006 20:52:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=979#p979</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=974#p974</link>
			<description><![CDATA[<p>Понятно. Сайт посмотрел, и если честно, мне эта задача кажется не совсем простой. Подумаю...</p>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Mon, 30 Oct 2006 14:38:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=974#p974</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=973#p973</link>
			<description><![CDATA[<p>сайт не секретный, просто на некоторых форумах это расценивается как реклама и удаляется.<br />вообще - gismeteo.ru<br />да, в этом то и весь смысл, чтоб я забыл про эту погоду. шедулер сделать и все. нужно 3 копии делать.</p>]]></description>
			<author><![CDATA[null@example.com (adm_tolik_in)]]></author>
			<pubDate>Mon, 30 Oct 2006 13:56:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=973#p973</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=971#p971</link>
			<description><![CDATA[<p>А сайт с погодой секретный? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Опиши чуть подробнее, каким образом надо из скрипта печатать. Чтобы вообще без участия человека сразу на принтер? Или оператор должен работать с диалогом &quot;Печать&quot;?</p>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Mon, 30 Oct 2006 13:15:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=971#p971</guid>
		</item>
		<item>
			<title><![CDATA[WSH: печать документа из IExplorer]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=969#p969</link>
			<description><![CDATA[<p>Пытаясь автоматизировать рутинные процессы столкнулся с проблемой:<br />мне необходимо каждый день распечатывать погоду в 3-х экземплярах.<br />с вызовом страницы проблем не возникло но на сайте необходимо перейти по ссылке &quot;Печать&quot;, что бы вызвать версию для печати + в скрипте нужно указать принтер (на клиенте)<br />как это все в скрипте прописать. подскажите или ссылочку на ресурс где это описывается, а то я сам не могу найти. спасибо.</p><p>set WshShell=WScript.CreateObject(&quot;WScript.Shell&quot;)<br />WshShell.Run(&quot;http://www.*****.ru/towns/34723.htm&quot;)</p>]]></description>
			<author><![CDATA[null@example.com (adm_tolik_in)]]></author>
			<pubDate>Mon, 30 Oct 2006 12:17:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=969#p969</guid>
		</item>
	</channel>
</rss>
