Link to home
Start Free TrialLog in
Avatar of Steve B
Steve BFlag for United States of America

asked on

VB script Do Until based on user input

I am trying to create a vbs file that will print a collection of Word documents in a folder X number of times as input by the user.  My problem is, I don't think it is formatted correctly.  If I run it and input 1, it doesn't do anything at all.  If I cancel the dialog box, it will print infinitely.  I am sure it is painfully obvious to someone what my problem is.  I am just not familiar enough with Do Until to know what is wrong.

Script is below:

number = Int(InputBox("Number of Copies?"))
count = 1

Do Until count = number
set shApp = CreateObject("shell.application")
currentPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
set shFolder = shApp.NameSpace( currentPath )
set files = shFolder.Items()
for each files in files

    if <> "*.txt" then
        'msgbox("printing "&
                                files.InvokeVerbEx ("Print")

    end if
    count = count + 1


There is probably a better way to accomplish this.

Avatar of ste5an
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve B


This worked a treat.  Thanks for taking the time to produce a working sample!