Jumat, 07 Juni 2013

[ExcelVBA] Before close procedure

 

I have put
this procedure in This workbook section.

It starts
to run when user try to close workbook, and if he doesn't type the correct
password, the closure 
is cancelled and msgbook ("No closing").

So far, so
good!

But if the
user types the correct password, the same inputbox is shown twice before the
workbook is closed.
Why? And
can someone help me with a fix?
---------------
'Private
Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts
= False
svar =
InputBox("password!")
If
UCase(svar) = "HNN" Then
ActiveWorkbook.Close
SaveChanges:=False
Else
Cancel =
True
MsgBox
("no closing!")
End If
End
End Sub

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (8)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar