Error Expected Loop VBScript
Posted
by
Yoko21
on Stack Overflow
See other posts from Stack Overflow
or by Yoko21
Published on 2013-11-01T23:21:47Z
Indexed on
2013/11/06
9:53 UTC
Read the original article
Hit count: 136
I have a script that opens up an excel file if the password provided is correct. If its wrong, it prompts a message. It works perfectly when I add a loop at the end. However, the problem is whenever the password is wrong the script won't stop asking for the password because of the loop. What I want is the script to quit/close if the password is wrong. I tried to remove the loop and replaced it with "wscript.quit" but it always prompts the message "expected loop". Here is the code I made.
password = "pass"
do
ask=inputbox ("Please enter password:","DProject")
select case ask
case password
answer=true
Set xl = CreateObject("Excel.application")
xl.Application.Workbooks.Open "C:\Users\test1\Desktop\test.xlsx"
xl.Application.Visible = True
Set xl = Nothing
wscript.quit
end select
answer=false
x=msgbox("Password incorrect... Aborting")
loop until answer=true
Is it possible to put a message like that counts when aborting. like "Aborting in 3.... 2... 1".
© Stack Overflow or respective owner