Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - unable to catch WordApplication events on vista32 using Wod 2007

Reply
 
Old 06-06-2009   #1 (permalink)
hls


 
 

unable to catch WordApplication events on vista32 using Wod 2007

My example below is unable to catch WordApplication events,
can any one see aproblem with my code.
I am attempting to trap the BeforePrint event. cancel = true,
then use Envelope.PrintOut

Thank you for any help.
'
Dim sTo,sFrom
sTo = "John Jones" & vbcrlf & "1313 Miller St." & vbcrlf & "Dover, De 19901"
sFrom = "Mike Jones" & vbcrlf & "3333 Miller St." & vbcrlf & "Wilmington, De
19954"
'
'
set wd = new wrd
wd.show
wscript.sleep 10000
wd.Quit
set wd = nothing

'
Class Wrd

Dim w,d
private sub class_Initialize
Set w = wscript.createobject("Word.Application","w_")
set d = w.documents.add
WScript.ConnectObject d, "d_"
d.envelope.insert ,sTo,,,sFrom
end sub

Sub Show()
If Not w is nothing then
d.printpreview
w.Visible = True
w.Activate
end if
end sub

Sub Quit()
If Not w is nothing then
If w.Visible = True Then
w.windowstate = 2
End if
w.Quit 0
end if
end sub

private sub w_NewDocument(Doc)
msgbox "w_NewDocument"
end sub

private sub w_DocumentBeforeClose(Doc, Cancel)
msgbox "w_DocumentBeforeClose"
end sub

private sub w_DocumentBeforePrint(Doc, Cancel)
msgbox "w_DocumentBeforePrint"
end sub

private sub Class_Terminate()
set d = nothing
If Not w is nothing then
w.Quit 0
end if
set w = nothing
End Sub

End Class


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Unable to find BDD 2007 for x64 OS's Software
unable to print in Office 2007 Microsoft Office
Unable to shutdown after Office 2007 Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46