How to print files vbscript?

Asked By 20 points N/A Posted on -

Hello fellows,

How to print files VBscript?

I want to automatically print files using visual basic javascript, my computer shop system was not yet done but I want to print the gui or graphical user interface for my documentation.

Is there a way to print a file in vb environment?


Rebecca Green.

Best Answer by Aust Wilson
Best Answer
Best Answer
Answered By 5 points N/A #173672

How to print files vbscript?


Hi! All you have to do is use the "Shell" object, which is already built into the operating system for printing text files.

Shell object has a method called "InvokeVerbEx" that allows you to perform the tasks which you see when you right-click a file using Windows Explorer. Choose one of your text files, right-click it and look on the options that will pop into the screen (e.g. Open, Print, Edit, Cut, Copy, Delete).

Shell allows you to do all these tasks programmatically. This is the script,

TargetFolder = "C:Logs"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items
For Each objItem in colItems

Next, connect to C:/Logs folder then grab all the items you can see in that folder. Store the set of files in the variable "colItems"  with this code: Set colItems = objFolder.Items

Make sure that C:/Logs contains only log files which are the ones you want to print. If C:/Logs contains some files we don't want to print, put code that differentiates the files you want to print from those you don't want.

For every single item in the collection or every file in the folder, we will use the "InvokeVerbEx" method. Include this in every file: objItem.InvokeVerbEx("Print")

Just run this script and each file will be printed one after the other.

For any further questions you can check out this site.

Answered By 0 points N/A #173673

How to print files vbscript?


Hello Rebecca.

1. To print a gui for documentation, you can capture what's on the whole screen and save it as a picture. All you have to do is press the "prt sc" key on your keyboard, open a new Word, paint file (any program that supports pictures) and paste it there. You can save the file and print it from there.

2. On the other hand, if you want to print from visual basic environment, you'll need a code for that.

You can get a copy of the code here:

I hope this information is useful for what you have in mind.



Login/Register to Answer

Related Questions