Results 1 to 5 of 5

Need help with my force enable macros code being autosaved

Threaded View

  1. #1
    Registered User
    Join Date
    01-30-2015
    Location
    Albany, NY
    MS-Off Ver
    Whatever the client has
    Posts
    8

    Need help with my force enable macros code being autosaved

    Okay so I am no way a macros person and have barely used until the other day. A client has a shared workbook that needs to be password protected, but have a read only option. I then made the save buttons password protected so they couldn't save it as a copy. This macro I found online doesnt show them other sheets until they enable macros. My problem is it wants to auto save and asks for a password but not everyone will have the password. I see the macro has this situation covered but it's not working for me. Help would be greatly appreciated!!!
    Option Explicit
     
    Private Sub Workbook_Open()
         
        With Application
             'disable the ESC key
            .EnableCancelKey = xlDisabled
            .ScreenUpdating = False
             
            Call UnhideSheets
             
            .ScreenUpdating = True
             're-enable ESC key
            .EnableCancelKey = xlInterrupt
        End With
         
    End Sub
     '
    Private Sub UnhideSheets()
         '
        Dim Sheet As Object
         '
        For Each Sheet In Sheets
            If Not Sheet.Name = "Prompt" Then
                Sheet.Visible = xlSheetVisible
            End If
        Next
         '
        Sheets("Prompt").Visible = xlSheetVeryHidden
         '
        Application.Goto Worksheets(1).[A1], True '< Optional
         '
        Set Sheet = Nothing
        ActiveWorkbook.Saved = True
         
    End Sub
     
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        With Application
            .EnableCancelKey = xlDisabled
            .ScreenUpdating = False
             
            Call HideSheets
             
            .ScreenUpdating = True
            .EnableCancelKey = xlInterrupt
        End With
    End Sub
     
    Private Sub HideSheets()
         '
        Dim Sheet As Object '< Includes worksheets and chartsheets
         '
        With Sheets("Prompt")
             '
             'the hiding of the sheets constitutes a change that generates
             'an automatic "Save?" prompt, so IF the book has already
             'been saved prior to this point, the next line and the lines
             'relating to .[A100] below bypass the "Save?" dialog...
            If ThisWorkbook.Saved = True Then .[A100] = "Saved"
             '
            .Visible = xlSheetVisible
             '
            For Each Sheet In Sheets
                If Not Sheet.Name = "Prompt" Then
                    Sheet.Visible = xlSheetVeryHidden
                End If
            Next
             '
            If .[A100] = "Saved" Then
                .[A100].ClearContents
                ThisWorkbook.Save
            End If
             '
            Set Sheet = Nothing
        End With
         '
    End Sub
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim Password As String
    Dim EnteredPassword As String
    
    Password = "password1"
    EnteredPassword = InputBox("Enter password to save changes")
    If EnteredPassword <> Password Then
    Cancel = True
    MsgBox ("Password incorrect, file not saved")
    End If
    
    End Sub
    Last edited by FDibbins; 02-03-2015 at 04:14 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Prevent Editing after Date and Force Enable Macros
    By efaden in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2014, 03:11 PM
  2. Force Enable Macros with Password on Save
    By simmo86 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2010, 11:30 AM
  3. force enable macros lag
    By FRIEL in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-07-2009, 02:13 PM
  4. [SOLVED] Force to enable macros
    By Denys in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2006, 09:30 AM
  5. How can force enable macros to be able to open my workbook?
    By kcdonaldson in forum Excel General
    Replies: 3
    Last Post: 12-05-2005, 02:20 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1