<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Controlling When VBScript Events Are Handled</title>
	<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/</link>
	<description>Ask the Windows Guru!</description>
	<pubDate>Sun, 01 Aug 2010 06:41:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Harold Little</title>
		<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-50561</link>
		<dc:creator>Harold Little</dc:creator>
		<pubDate>Wed, 22 Jul 2009 13:32:45 +0000</pubDate>
		<guid>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-50561</guid>
		<description>I did remove the "On" in Wd_OnQuit. I can receive the Quit event.
I can not catch the "BeforeDucumentPrint" event. It does appear if the event needs to pass params, I can not catch it.</description>
		<content:encoded><![CDATA[<p>I did remove the &#8220;On&#8221; in Wd_OnQuit. I can receive the Quit event.<br />
I can not catch the &#8220;BeforeDucumentPrint&#8221; event. It does appear if the event needs to pass params, I can not catch it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webJose</title>
		<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-50338</link>
		<dc:creator>webJose</dc:creator>
		<pubDate>Tue, 21 Jul 2009 16:18:27 +0000</pubDate>
		<guid>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-50338</guid>
		<description>Oops, forgot the tracking as I'm interested in knowing if you succeed. :)</description>
		<content:encoded><![CDATA[<p>Oops, forgot the tracking as I&#8217;m interested in knowing if you succeed. <img src='http://www.nilpo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webJose</title>
		<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-50337</link>
		<dc:creator>webJose</dc:creator>
		<pubDate>Tue, 21 Jul 2009 16:16:38 +0000</pubDate>
		<guid>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-50337</guid>
		<description>Harold:

See http://msdn.microsoft.com/en-us/library/aa211873(office.11).aspx.

Try the sub header:

Sub objWD_DocumentBeforePrint(ByVal oDoc, ByRef Cancel)

instead of your header.

As for the quit event, shouldn't it be:

Sub objWD_Quit

instead of using "OnQuit"?</description>
		<content:encoded><![CDATA[<p>Harold:</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/aa211873" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa211873</a>(office.11).aspx.</p>
<p>Try the sub header:</p>
<p>Sub objWD_DocumentBeforePrint(ByVal oDoc, ByRef Cancel)</p>
<p>instead of your header.</p>
<p>As for the quit event, shouldn&#8217;t it be:</p>
<p>Sub objWD_Quit</p>
<p>instead of using &#8220;OnQuit&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harold Little</title>
		<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-40753</link>
		<dc:creator>Harold Little</dc:creator>
		<pubDate>Sun, 07 Jun 2009 13:34:55 +0000</pubDate>
		<guid>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-40753</guid>
		<description>''''''''''''''''''''''''''''
' Attempting to trap the
' objWd_DocumentBeforePrint
' Event
''''''''''''''''''''''''''''
'
Dim sTo,sFrom,objWD,objDoc
'
sTo = "John Jones" &#38; vbcrlf &#38; "1313 Miller St."
sTo = sTo &#38; vbcrlf &#38; "Dover, De 19901"
sFrom = "Mike Jones" &#38; vbcrlf &#38; "3333 Miller St."
sFrom = sFrom &#38; vbcrlf &#38; "Wilmington, De 19954"
'
'
Set objWD = WScript.CreateObject("Word.Application","objWD_")
Set objDoc = objWD.Documents.Add
Set Env = objWD.ActiveDocument.Envelope
Env.Insert ,sTo,,,sFrom

objWD.windowstate = 2
objWD.PrintPreview = true

WScript.ConnectObject objWD, "objWD_"
WScript.ConnectObject objDoc, "objDoc_"

objWD.Visible = True
objWD.windowstate = 0

Do While objWD.Visible
 WScript.Sleep 200
 If objWD.PrintPreview = False Then Exit Do
Loop

Do while objWD.BackgroundPrintingStatus &#62; 0
 WScript.Sleep 100
Loop

'
objWD.windowstate = 2
WScript.Sleep 25
objWD.Quit 0

Set objDoc = Nothing
Set objWD = Nothing

''''' Object Events ''''''''

 
Sub objWD_DocumentChange
 ' Event Caught
 MsgBox "The current document has been changed."
End Sub

Sub objWD_DocumentBeforePrint
 Cancel = True
 Msgbox "BeforeDucumentPrint",,"objWD_BeforeDucumentPrint"
 Env.PrintOut
End Sub

Sub objWD_OnQuit
 Msgbox "objWD_Quit" 
 WScript.Quit
End Sub

Thank you so much for assistance.
Harold</description>
		<content:encoded><![CDATA[<p>&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;<br />
&#8216; Attempting to trap the<br />
&#8216; objWd_DocumentBeforePrint<br />
&#8216; Event<br />
&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;&#8221;<br />
&#8216;<br />
Dim sTo,sFrom,objWD,objDoc<br />
&#8216;<br />
sTo = &#8220;John Jones&#8221; &amp; vbcrlf &amp; &#8220;1313 Miller St.&#8221;<br />
sTo = sTo &amp; vbcrlf &amp; &#8220;Dover, De 19901&#8243;<br />
sFrom = &#8220;Mike Jones&#8221; &amp; vbcrlf &amp; &#8220;3333 Miller St.&#8221;<br />
sFrom = sFrom &amp; vbcrlf &amp; &#8220;Wilmington, De 19954&#8243;<br />
&#8216;<br />
&#8216;<br />
Set objWD = WScript.CreateObject(&#8221;Word.Application&#8221;,&#8221;objWD_&#8221;)<br />
Set objDoc = objWD.Documents.Add<br />
Set Env = objWD.ActiveDocument.Envelope<br />
Env.Insert ,sTo,,,sFrom</p>
<p>objWD.windowstate = 2<br />
objWD.PrintPreview = true</p>
<p>WScript.ConnectObject objWD, &#8220;objWD_&#8221;<br />
WScript.ConnectObject objDoc, &#8220;objDoc_&#8221;</p>
<p>objWD.Visible = True<br />
objWD.windowstate = 0</p>
<p>Do While objWD.Visible<br />
 WScript.Sleep 200<br />
 If objWD.PrintPreview = False Then Exit Do<br />
Loop</p>
<p>Do while objWD.BackgroundPrintingStatus &gt; 0<br />
 WScript.Sleep 100<br />
Loop</p>
<p>&#8216;<br />
objWD.windowstate = 2<br />
WScript.Sleep 25<br />
objWD.Quit 0</p>
<p>Set objDoc = Nothing<br />
Set objWD = Nothing</p>
<p>&#8221;&#8221;&#8217; Object Events &#8221;&#8221;&#8221;&#8221;</p>
<p>Sub objWD_DocumentChange<br />
 &#8216; Event Caught<br />
 MsgBox &#8220;The current document has been changed.&#8221;<br />
End Sub</p>
<p>Sub objWD_DocumentBeforePrint<br />
 Cancel = True<br />
 Msgbox &#8220;BeforeDucumentPrint&#8221;,,&#8221;objWD_BeforeDucumentPrint&#8221;<br />
 Env.PrintOut<br />
End Sub</p>
<p>Sub objWD_OnQuit<br />
 Msgbox &#8220;objWD_Quit&#8221;<br />
 WScript.Quit<br />
End Sub</p>
<p>Thank you so much for assistance.<br />
Harold</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nilpo</title>
		<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-40751</link>
		<dc:creator>Nilpo</dc:creator>
		<pubDate>Sun, 07 Jun 2009 13:03:44 +0000</pubDate>
		<guid>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-40751</guid>
		<description>Not all events may be exposed through the scripting interface.  Can you post the code you are trying so I can try it myself?</description>
		<content:encoded><![CDATA[<p>Not all events may be exposed through the scripting interface.  Can you post the code you are trying so I can try it myself?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harold Little</title>
		<link>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-40750</link>
		<dc:creator>Harold Little</dc:creator>
		<pubDate>Sun, 07 Jun 2009 12:31:38 +0000</pubDate>
		<guid>http://www.nilpo.com/2008/07/windows-scripting/controlling-when-vbscript-events-are-handled/#comment-40750</guid>
		<description>Using the example for WScript.ConnectObject objWord, "wd_", I was able to trap the wd_DocumentChange event but unable to trp the WD_BeforeDucumentPrint event, using Vista32 and Word 2007. Several events including ws_OnQuit I am unable to catch, If you have a moment.
Thank you
Harold</description>
		<content:encoded><![CDATA[<p>Using the example for WScript.ConnectObject objWord, &#8220;wd_&#8221;, I was able to trap the wd_DocumentChange event but unable to trp the WD_BeforeDucumentPrint event, using Vista32 and Word 2007. Several events including ws_OnQuit I am unable to catch, If you have a moment.<br />
Thank you<br />
Harold</p>
]]></content:encoded>
	</item>
</channel>
</rss>
