+ Reply to Thread
Results 1 to 5 of 5

Disable Delete Comment, Edit Comment, Show/Hide Comment

  1. #1
    Registered User
    Join Date
    02-09-2013
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    31

    Disable Delete Comment, Edit Comment, Show/Hide Comment

    Hi,

    I have my workbook set up such that when a username and password is entered via a userform, certain cells in the worksheet are unprotected. I would like to disable Delete Comment, Edit Comment and Show/Hide Comment in the right-click command menu even when the worksheets are unprotected.

    Here is what I have:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    My Problem:
    1. I am getting "Run-time error 5: Invalid procedure call or argument" error at Application.CommandBars("Cell").Controls("Edit Comment").Enabled = True and Application.CommandBars("Cell").Controls("Insert Comment").Enabled = True. Why is this?
    2. When I open another Excel workbook, the Insert Comment option is greyed out. Why is this?

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Disable Delete Comment, Edit Comment, Show/Hide Comment

    I generally have a public Boolean variable that I set, then have that, so my sample is

    Public blnEnabled

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-09-2013
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    31

    Re: Disable Delete Comment, Edit Comment, Show/Hide Comment

    I am new to VBA, so would you mind explaining how blnEnabled works? I Googled it, but nothing comes up.

    Also, the very first right-click after the worksheets are unprotected does not actually disable Edit Comment, etc. On the second right-click, it gets disabled. Why is this?
    Last edited by Shanthan; 05-16-2013 at 08:03 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Disable Delete Comment, Edit Comment, Show/Hide Comment

    blnEnabled, is a variable name I have chosen, it is a space in memory to hold a TRUE or FALSE. This will be declared as Public meaning its accessible from where ever, so it can be used in other places, like if you're using a userform. Google Visual Basic Boolean Data Types, may help.

  5. #5
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Disable Delete Comment, Edit Comment, Show/Hide Comment

    The insert comment is greyed out because that line is successfully executed, but as you're getting an error later you are not being shown the command bar at the end of it. Looks like the top 3 lines are ok, just the edit comment one.

+ 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