Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: VB Coding in excel

    Hi All,

    Apologies if I have posted this thread incorrectly, I am a first time user and this is the first time I am posting a thread.

    Problem:

    I am trying to close an excel file but to do this I need to set a prompt that will ask the user if they have set a password to the sheet. If they answer no the file does not close which is fine, but I also need for the password screen to appear for the user to set a password(tools > options > security)
    How do I do this?

    This is the code I am using to prompt the user before close:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Dim Response As Long
    Response = MsgBox("Have you set a password to this file?", vbYesNo)
    If Response = vbNo Then
    Cancel = True
    End If

    End Sub

    Can I have help on this matter today please, need to complete and send out

    Cheers

    Sam

  2. #2
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    Hi,

    Add this line of code:
    Code:
    Application.Dialogs(xlDialogWorkbookProtect).Show
    Hope that helps...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •