+how to delete an inputbox

  • Hi. I have a program where I have an inputbox in the 'Workbook event', that prompts me to assign a password to access the file, without going through the tedium of opening the file, going through the disclaimer sheet and various hoops to get to the password area. That part works fine.

    Now what I need, is to delete this inputbox as soon as the password is inserted, otherwise anyone will get the inputbox on the "Sign In" sheet, when they open the file...then change the password to whatever.

    Here is what I have for the code. Just one line with syntax problem...I think


    Thanks so much

    Jimmy

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • On second thought...I can't delete the sub while I'm standing in it. Right?

    I'm calling the sub Inputbox2 in my workbook open event, and actually need to delete it, directly after it has run, so It doesn't show up for a second go-round

    If that makes sense

    HELP please with the syntax

    Thanks Jimmy

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • .

    This is one method ...


    In the Workbook_Open event, place a call to your sub INPUTBOX2.


    The last lines in your INPUTBOX2 sub should include the macro code from this resource : https://www.ozgrid.com/VBA/delete-module.htm and direct

    that code to delete the Workbook_Open module. I haven't tested it here but it should work.


    Another method would be to use a "flag" on a hidden sheet. When the password has been assigned, set the flag to the number 1 ... or the letter A ... or

    perhaps even the word PASSWORD. Then you will need to change your Workbook_Open module to first check for this flag. If the flag exists ... the program

    by-passes the password sheet. The user never sees it. If the flag doesn't exist, the Password sheet is displayed.


    HTH

  • You just need to run a check to see if the user has previously entered a password. Can you attach an example workbook.


    Here's a userform that allows you to a log in like other programs. It is an admin feature and allows passords to be amended.

  • Hey Roy. I forgot to mention that I'm a senior on a govt pension and can't afford your recommendation to hire someone to help with the userform. I guess that is why I check on the forums for help...LOL. (just trying to keep the mind active with these projects). You said you want to delete my posts. Why is that? I really need a bit more help on this issue.

    btw. The link you sent me locked up my computer. I had to go to task manager to dump it. Anyway please let me know if I've done something to offend you. That was not my intent whatsoever

    Thanks JimmyB

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • The link is PASSWORD-FORM-7.xlsm. Tried on 2 different computers and locked up both...just dings when clicked anywhere...had to disable it with task manager

    This link opens up the page that I've attached which mentions "if I need help with the project pleas contact sales&excel-it.com" for a quotation"

    I thought that it was driven by you... Sorry my mistake.

    Anyway I really need my simple question answered that I posted in the thread post to 'Logit'. You advised that you're deleting my posts, so should I just start a new thread?

    Lot of confusion here today...sheesh


    Maybe you can help me?


    I need to delete the line "call inputbox2" on my workbook event. I found the sub to delete that line of code but I get error "Object Required" on the line...Can you please help? When it says object required I draw a blank...(my Nemesis


    Thanks so much...Sorry for the confusion. I just don't want to offend anyone


    Code
    Sub DeleteCodeLines()
    ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.DeleteLines 42,1
    End Sub

    THANKS Roy

    JimmyB

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • .

    I tested this code here and it removes the ThisWorkbook_Open macro :


    Code
    Dim wb As Workbook
        Set wb = ThisWorkbook
            With wb.VBProject.VBComponents("ThisWorkbook").CodeModule   '<--- change to ThisWorkbook for that module
        
                    .DeleteLines 1, .CountOfLines
        
            End With
        
        MsgBox "Done...", 64
  • You replied to this thread by creating a new one. That's the one that needs deleting.


    The screen shot shows a userform to enable a user to login. It doesn't lock anything, that userform example has been used by hundreds of people. Al yoy need is to select a username and enter the relevant password that is on the sheet for demo purposes.

  • Well Roy, I'm not trying to be impossible but the link that you sent me locked up my computer and i needed to reset it in task manager (I just tried it again) with the same results. The url that you just sent me, comes up with "Page not found".

    The reason that I started a new thread is because you threatened to delete my posts (Post #6) and I still needed help on the issue. (Post #5)

    Just sayin'

    Have a great day

    Sorry we can't seem to get on well

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • I didn't threaten to delete your posts. I posted after the post appeared and was alerted by someone reporting it.


    You are being argumentative, the screen shot that you posted showed the UserForm in my example workbook, not a locked up computer. The password form has been available for many years and never had a problem, why it should on your computer I don't know. Have you actually tried selecting a name in it?

  • Yeah...still the same. anyway the problem has been solved with logits post. Sorry I didn't mean to create a peeing contest. don't want to cause any more grief...thanks for your help. I know you are acting with best intentions...signing off for now

    Thanks

    JimmyB

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!