Avatar of Steve B
Steve B
Flag 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
    count = count + 1


There is probably a better way to accomplish this.

VB Script

Avatar of undefined
Last Comment
Steve B

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Steve B

This worked a treat.  Thanks for taking the time to produce a working sample!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes