I have found another way to print files from a folder. However, it can't print .prn or .doc files.
Here is the code of "printall.vbs"
- set shApp = createobject("shell.application")
-
set shFolder = shApp.namespace("C:\Documents and Settings\Administrator\Desktop\Form
-
Generator\PrintAll")
-
set shItems = shFolder.Items()
-
for each shItem in shItems
-
-
shItem.invokeverb "&Print"
-
-
next
-
I tried to create if-statements to cater for .prn and .doc, but i only have a vague idea to do it. So, it can't work.
- set shApp = createobject("shell.application")
-
set shFolder = shApp.namespace("C:\Documents and Settings\Administrator\Desktop\Form Generator\PrintAll")
-
set shItems = shFolder.Items()
-
for each shItem in shItems
-
-
-
If shItem.Extension = "prn" Then
-
-
set wshshell=createobject("wscript.shell")
-
-
iret=wshshell.run("%comspec% /c copy /b " & chr(34) & prnfilespec & chr(34) & " prn",0,false)set
-
-
wshshell=nothing
-
-
ElseIf shItem.Extension = "doc" Then
-
-
wordfilespec=shItem
-
-
set oword=createobject("word.application")on error resume next
-
with oword
-
.visible=false
-
.documents.open wordfilespec
-
.printout
-
do until .backgroundprintingstatus=0
-
wscript.sleep 100
-
loopend withoword.activedocument.close
-
falseoword.quitset
-
oword=nothingon error goto 0
-
-
Else
-
-
shItem.invokeverb "&Print"
-
-
End If
-
-
-
next
-
-