Hi,
I have this working vbs script that currently prints all files and all pages in a folder with a specific file extension.
I need to add a line that will for each opened document, move to the end of the document and prints just the last page.
so, how can I just print the last page of all the files. the problem is that each file may have different number of pages.
I tried bookmark end of document, goto last page, etc but not quite achieving, please advice. thank you.
see the bold section, thanks.
'--------------------------------------------------------------------
'Print All XML documents using WORD
'--------------------------------------------------------------------
Dim objFSO, objShell
Dim objWord, docWord
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
'Set objShell = CreateObject ("Shell.Application")
'Set objFolder = objShell.Namespace ("M:\IMSU\PrintFolder")
' GET the current path of the script
strPath = Wscript.ScriptFullName
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
ext = InputBox("Enter the file extention (without the dot): ")
ext = ucase(ext)
' Prompt and make sure
ccode = MsgBox("Print all " & ext & "files from folder" & vbCRLF & "[" & strfolder & "]" & vbCRLF & vbCRLF & "Are you sure?", 4)
If ccode <> vbYES Then wscript.quit
Set folder = objFSO.GetFolder(strFolder)
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
For Each file in folder.Files
'wscript.echo file.Name
If right(ucase(file.Name),len(ext)) = ext Then
Set docWord = objWord.Documents.Open(strFolder & "\" & file.Name)
objWord.ActiveDocument.Printout
objWord.ActiveDocument.Saved = True
objWord.ActiveDocument.Closee
End If
Next
ObjWord.Quit
I have this working vbs script that currently prints all files and all pages in a folder with a specific file extension.
I need to add a line that will for each opened document, move to the end of the document and prints just the last page.
so, how can I just print the last page of all the files. the problem is that each file may have different number of pages.
I tried bookmark end of document, goto last page, etc but not quite achieving, please advice. thank you.
see the bold section, thanks.
'--------------------------------------------------------------------
'Print All XML documents using WORD
'--------------------------------------------------------------------
Dim objFSO, objShell
Dim objWord, docWord
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
'Set objShell = CreateObject ("Shell.Application")
'Set objFolder = objShell.Namespace ("M:\IMSU\PrintFolder")
' GET the current path of the script
strPath = Wscript.ScriptFullName
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
ext = InputBox("Enter the file extention (without the dot): ")
ext = ucase(ext)
' Prompt and make sure
ccode = MsgBox("Print all " & ext & "files from folder" & vbCRLF & "[" & strfolder & "]" & vbCRLF & vbCRLF & "Are you sure?", 4)
If ccode <> vbYES Then wscript.quit
Set folder = objFSO.GetFolder(strFolder)
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
For Each file in folder.Files
'wscript.echo file.Name
If right(ucase(file.Name),len(ext)) = ext Then
Set docWord = objWord.Documents.Open(strFolder & "\" & file.Name)
objWord.ActiveDocument.Printout
objWord.ActiveDocument.Saved = True
objWord.ActiveDocument.Closee
End If
Next
ObjWord.Quit