Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for printdoc.vbs

(view source code of printdoc.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim intRC, objWord, strDocFile
  4.  
  5. With WScript.Arguments
  6. 	If .Unnamed.Count = 1 Then
  7. 		strDocFile = WScript.Arguments.Unnamed(0)
  8. 	Else
  9. 		Syntax
  10. 	End If
  11. 	If .Named.Count > 0 Then Syntax
  12. End With
  13.  
  14. Set objWord = CreateObject( "Word.Application" )
  15.  
  16. intRC = objWord.Documents.Open( strDocFile )
  17.  
  18. objWord.Visible        = False
  19. objWord.ScreenUpdating = False
  20.  
  21. objWord.ActiveDocument.PrintOut False
  22.  
  23. objWord.ActiveDocument.Close 0 
  24.  
  25. objWord.Quit
  26.  
  27. Set objWord = Nothing
  28.  
  29.  
  30. Sub Syntax
  31. 	Dim strMsg
  32. 	strMsg = "PrintDoc.vbs,  Version 1.00" _
  33. 	       & vbCrLf _
  34. 	       & "Print a specified MS Word document on the default printer" _
  35. 	       & vbCrLf & vbCrLf _
  36. 	       & "Usage:  PRINTDOC.VBS  word_document" _
  37. 	       & vbCrLf & vbCrLf _
  38. 	       & "Note:   This script requires MS Word to print the document." _
  39. 	       & vbCrLf & vbCrLf _
  40. 	       & "Based on a script by Arnout van der Vorst" _
  41. 	       & vbCrLf _
  42. 	       & "arnoutvandervorst.blogspot.com/2008/03/vbscript-to-automatically-insert.html" _
  43. 	       & vbCrLf & vbCrLf _
  44. 	       & "Written by Rob van der Woude" _
  45. 	       & vbCrLf _
  46. 	       & "http://www.robvanderwoude.com"
  47. 	WScript.Echo strMsg
  48. 	WScript.Quit 1
  49. End Sub
  50.  

page last uploaded: 2017-04-06, 13:33