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 files.name <> "*.txt" then
        'msgbox("printing "&files.name)
                                files.InvokeVerbEx ("Print")

    end if
next
    count = count + 1
Loop

--------------

There is probably a better way to accomplish this.


ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
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

ASKER

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