T
Thereal Robeen
I am trying to automate the printing of documents from a specified folder on
our server. I am trying to write a VB Script to do this and run it as a
scheduled task to check the folder every minute for any files in there, print
them, then delete them. Here's what I have so far, I have only begun testing
the Word doc portion.
...............<BEGIN CODE>.................
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("M:\IMSU\PrintFolder")
For Each strFileName in objFolder.Items
If objFolder.GetDetailsOf (strFileName, 2) = "Microsoft Word Document" Then
Set objWord = CreateObject("Word.Application")
set docWord = objWord.Document.Open(strFileName)
objWord.ActiveDocument.Printout Background:=False
objWord.ActiveDocument.Close saveChanges:=wdDoNotSaveChanges
objWord.Quit
elseif objFolder.GetDetailsOf (strFileName, 2) = "Microsoft Excel
Workbook" Then
'Future Code
elseif objFolder.GetDetailsOf (strFileName, 2) = "Microsoft PowerPoint
Presentation" Then
'Future Code
else 'Print other files if not office docs
objFolder.Item("M:\IMSU\PrintFolder\" &
strFileName).InvokeVerbEx("Print")
end if
Next
Const DeleteReadOnly = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("M:\IMSU\PrintFolder\*.*"), DeleteReadOnly
....................<END CODE>...................
The Delete portion works OK, but I keep getting a Windows Script Host
'Expected Statement' Compile Error on the PrintOut line. Any help would be
greatly appreciated. Thank you.
our server. I am trying to write a VB Script to do this and run it as a
scheduled task to check the folder every minute for any files in there, print
them, then delete them. Here's what I have so far, I have only begun testing
the Word doc portion.
...............<BEGIN CODE>.................
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("M:\IMSU\PrintFolder")
For Each strFileName in objFolder.Items
If objFolder.GetDetailsOf (strFileName, 2) = "Microsoft Word Document" Then
Set objWord = CreateObject("Word.Application")
set docWord = objWord.Document.Open(strFileName)
objWord.ActiveDocument.Printout Background:=False
objWord.ActiveDocument.Close saveChanges:=wdDoNotSaveChanges
objWord.Quit
elseif objFolder.GetDetailsOf (strFileName, 2) = "Microsoft Excel
Workbook" Then
'Future Code
elseif objFolder.GetDetailsOf (strFileName, 2) = "Microsoft PowerPoint
Presentation" Then
'Future Code
else 'Print other files if not office docs
objFolder.Item("M:\IMSU\PrintFolder\" &
strFileName).InvokeVerbEx("Print")
end if
Next
Const DeleteReadOnly = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("M:\IMSU\PrintFolder\*.*"), DeleteReadOnly
....................<END CODE>...................
The Delete portion works OK, but I keep getting a Windows Script Host
'Expected Statement' Compile Error on the PrintOut line. Any help would be
greatly appreciated. Thank you.