|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
General Scripting - How to print a file
I read the tutorial on how to print files in a folder, and that worked great, but I just need to print one file and cannot get it to work. This is what I've tried so far:
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\text.txt", 1) Set objShell = CreateObject("Shell.Application") objFile.InvokeVerbEx("Print") objFile.Close -------------------------------------------- That didn't work so I tried this: TargetFile = "c:\text.txt" Set objShell = CreateObject("Shell.Application") Set objFile = objShell.Open(TargetFile) objFile.InvokeVerbEx("Print") That also doesn't work along with about 20 other variations I have tried. I can't seem to set the file as an object, and then print the file. |
|
#2
|
||||
|
||||
|
Code:
TargetFolder = "C:\"
TargetFile = "test.txt"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items
iFileCount = colItems.count
i = 0
For each objItem in colItems
If objItem = TargetFile Then
objItem.InvokeVerbEx("Print")
Exit For
End If
i = i + 1
If i = iFileCount Then Msgbox("File not found")
Next
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon
Last edited by keep_it_simple : April 29th, 2008 at 07:06 PM. Reason: used requested file name |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > General Scripting - How to print a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|