Loading
Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: Temporarily stopping an inputbox in a sub

  1. #1
    Join Date
    28th September 2012
    Posts
    12

    Temporarily stopping an inputbox in a sub

    Hello,

    I have the following sub in a Workbook to prevent users of a spreadsheet from saving it:

    VB:
    Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) 
        Dim Password As String 
        Dim EnteredPassword As String 
         
         
        Password = "1234" 
        EnteredPassword = InputBox("Enter password to save changes") 
        If EnteredPassword <> Password Then 
            Cancel = True 
            MsgBox ("Password incorrect, file not saved") 
        End If 
         
         
    End Sub 
    
    
    There is another sub that runs after the user clicks a button on a worksheet. During this script the worksheets are saved as different .csv files to be used by another program.

    How can I avoid the pop up asking for a password to save during that part of the code?

    Thanks,
    Ross

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    10th January 2007
    Location
    Borneo
    Posts
    2,899

    Re: Temporarily stopping an inputbox in a sub

    With the other subroutine put this at the start of the code
    VB:
    Application.EnableEvents = False 
    
    
    and this at the end
    VB:
    Application.EnableEvents = True 
    
    
    We now have a reputation system in place. It can be found on the 'Star' icon on the bottom left hand side of the post

  3. #3
    Join Date
    28th September 2012
    Posts
    12

    Re: Temporarily stopping an inputbox in a sub

    That works! Thanks

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    10th January 2007
    Location
    Borneo
    Posts
    2,899

    Re: Temporarily stopping an inputbox in a sub

    You're welcome.
    We now have a reputation system in place. It can be found on the 'Star' icon on the bottom left hand side of the post

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. temporarily display userform
    By Pete39 in forum Excel General
    Replies: 9
    Last Post: June 27th, 2012, 06:34
  2. Temporarily Show Userform
    By iamstevie in forum Excel General
    Replies: 3
    Last Post: December 9th, 2006, 07:15
  3. Hide application temporarily
    By SuitedACes in forum Excel General
    Replies: 8
    Last Post: July 12th, 2006, 13:53
  4. Temporarily change login Name 2
    By Ray Drayson in forum Excel General
    Replies: 2
    Last Post: February 7th, 2006, 19:07
  5. Temporarily displaying userforms
    By LOEzell in forum Excel General
    Replies: 1
    Last Post: January 27th, 2005, 07:36

Bookmarks

Posting Permissions

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