Error Expected Loop VBScript
- by Yoko21
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".