+ Reply to Thread
Results 1 to 2 of 2

Disable Delete/Edit/Clear Comment using VBA

  1. #1
    Registered User
    Join Date
    02-27-2014
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    2

    Disable Delete/Edit/Clear Comment using VBA

    Hello,
    I have use below code to protect all worksheets and in the same time disable delete AND edit comment. I worked out that some of the protection options (AllowXXX) mess up disable function. I want the worksheets to be protected, but still allow users to unhide columns/rows and sort.
    Also I noticed that despite the code below users can still go to "Editing" top Excel menu and use Clear Comment, which makes below effort useless.
    Will appreciate any comment. Thank you PK


    [Sub ProtectAll()
    Dim ws As Worksheet
    Dim myHaslo As String
    Dim objCTRL As CommandBarControl

    myHaslo = "123"

    For Each ws In Worksheets


    With Application.CommandBars("Cell")
    For Each objCTRL In .Controls
    If InStr(1, "Delete Co&mment/&Edit Co&mment", objCTRL.Caption) > 0 Then
    objCTRL.Enabled = False

    End If
    Next objCTRL
    End With
    Set objCTRL = Nothing

    ws.Protect Password:=myHaslo _
    , DrawingObjects:=False, Contents:=True, Scenarios:=False _
    , UserInterfaceOnly:=True, AllowFormattingCells:=False, AllowFormattingColumns:=True, AllowFormattingRows:=True _
    , AllowInsertingColumns:=False, AllowInsertingRows:=False, AllowInsertingHyperlinks:=False _
    , AllowDeletingColumns:=False, AllowDeletingRows:=False, AllowSorting:=True, AllowFiltering:=True _
    , AllowUsingPivotTables:=True

    Next ws

    End Sub][/CODE]

  2. #2
    Registered User
    Join Date
    02-27-2014
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Disable Delete/Edit/Clear Comment using VBA

    In the meantime I've found some coding to deactivate worksheet menu - my problem is that it doesn't work - thank you for your help.


    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Allow cell input, disable cell edit and delete
    By lzyshaman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2019, 11:46 AM
  2. Disable Delete Comment, Edit Comment, Show/Hide Comment
    By Shanthan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2013, 06:12 AM
  3. USERFORM: EDIT to include FIND, DELETE & CLEAR
    By srands in forum Excel General
    Replies: 2
    Last Post: 01-03-2013, 01:15 AM
  4. Replies: 0
    Last Post: 09-04-2008, 01:35 PM
  5. Disable the Delete Control in the Edit Menu
    By Virtual Hillbilly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2006, 05:55 AM

Tags for this Thread

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