+ Reply to Thread
Results 1 to 10 of 10

Active Buttons required

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-23-2007
    Location
    Essex, UK
    MS-Off Ver
    MS365 V2308
    Posts
    279

    Active Buttons required

    Well im back for another lesson on VBA. Ive tried to get this to work from what I've learnt in previous posts but I just keep screwing it up, so I have included the workbook with the buttons added but not active. What I need is some help on how to get them to do what I want.

    The buttons are located on the PFM Tracker sheet with what I need them to do. In addition I'll give you a breakdown of what is required.

    Currently when the workbook is opened the user is forced to activate the macros. One of these macros disables the Cut, Copy Paste features within Excel. I need the first button 'Enable Copy' to request a password for activation and once entered the Cut, Copy, Paste feature to be enabled. Then when finished the 2nd button 'Disable Copy' when clicked to re-activate the Cut, Copy, Paste Disabled macro.

    Hope that explains it. I have left the PFM Tracker sheet unprotected for who ever wants to play with it. (Not that protection would stop some)

  2. #2
    Forum Contributor
    Join Date
    03-23-2007
    Location
    Essex, UK
    MS-Off Ver
    MS365 V2308
    Posts
    279
    Bump..please ppl i need to get this to work

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Quote Originally Posted by ukphoenix
    Bump..please ppl i need to get this to work
    Hi,
    Can't you just protect the sheet, then un-protect it to modify?
    Private Sub CommandButton1_Click()
        Dim strName As String
    
        strName = InputBox(Prompt:="Password Please", _
                           Title:="Password required", Default:="Password")
    
        If strName = "1234" Then
            ActiveSheet.Unprotect Password:="password"
            MsgBox "Your VBA code here"
            ActiveSheet.Protect Password:="password"
        Else
            MsgBox "Wrong Password"
        End If
    
    End Sub
    Last edited by davesexcel; 07-06-2008 at 11:24 AM.

  4. #4
    Forum Contributor
    Join Date
    03-23-2007
    Location
    Essex, UK
    MS-Off Ver
    MS365 V2308
    Posts
    279
    I can see what your trying to do by unprotecting on the click of the button but this will not reverse the macro that disables the 'Cut Copy Paste' feature. This feature also needs to be re-enabled afterwards.

    The reason I need these buttons are that I need to copy some of the data once the sheet is completed. But what I dont want is for the workbook to be left with the copy, paste feature available so that any old Joe can start tampering, hence the fairly heavy measures taken.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Why not have your code check Environ("username"), and if it's you, don't disable cut and paste?

    BTW, don't forget to undo the disable when the workbook is deactivated (i.e., when users switch to another workbook in the same instance of Excel).

  6. #6
    Forum Contributor
    Join Date
    03-23-2007
    Location
    Essex, UK
    MS-Off Ver
    MS365 V2308
    Posts
    279
    Quote Originally Posted by shg
    Why not have your code check Environ("username"), and if it's you, don't disable cut and paste?

    BTW, don't forget to undo the disable when the workbook is deactivated (i.e., when users switch to another workbook in the same instance of Excel).
    Being a novice I aint got a clue how too...lol......example please

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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