Context Menu

rediffusion

Board Regular
Joined
Apr 24, 2019
Messages
60
Hi all!


Found the script "VBA" which is a little tweaked to fit your needs:


Code:
Sub Special_note()
Dim myComm As Comment
  If Not ActiveCell.Comment Is Nothing Then
    If MsgBox("The cell already contains a note, delete?", 4) - 7 Then
      ActiveCell.Comment.Delete
    Else: Exit Sub
    End If
  End If


  Set myComm = ActiveCell.AddComment
  With myComm.Shape 'exhibiting the required format
    .Height = 110
    .Width = 200
    .AutoShapeType = 1             'form
    .Fill.ForeColor.SchemeColor = 13 'fill
    .Line.ForeColor.RGB = RGB(255, 0, 0) 'line color
    .DrawingObject.Font.Name = "Consolas" 'font
    .DrawingObject.Font.FontStyle = "standard"
    .DrawingObject.Font.Size = 9    'font size
  End With
  'emulate the choice of " Change note"
  SendKeys "%": SendKeys "а": SendKeys "и": SendKeys "и": SendKeys "~": SendKeys "{BS}": SendKeys "{BS}"
End Sub


It works great!
But I wanted to add an item to the context Menu. File "PERSONAL.XLSB" in the folder XLSTART\ created scripts are saved and work in all "Excel" documents. But nothing is added to the "Context Menu". For this case used this script:
Code:
Sub SHD_CommAdd()
Dim MyPoint As CommandBarControl
  Set MyPoint = Application.CommandBars("Cell").Controls.Add
  MyPoint.Caption = "Special note"
  MyPoint.OnAction = "PERSONAL.XLSB!AddComm"
  MyPoint.Move , 10
End Sub


I get a window with this ERROR:
Unable to execute macro "PERSONAL.XLSB'AddComm" This macro may not be present in the current workbook, or all macros may be disabled.
In General, googled and found this "To add macro from the context menu, you need to keep THIS BOOK".
Got any vacine? I feel uncomfortable if only one document will be added to the item, it is convenient when working in all documents.


P.S.
To cancel there is a script (by the way it works):
Code:
Sub KMRangeClear()
  Application.CommandBars("Cell").Reset
End Sub


UPD:
:=::=::=::=::=::=::=::=::=::=::=::=::=::=::=::
1. If you have created a note the function to return "CTRL+Z" doesn't work (with the usual note is working). How to return to work?
2. If several items (called through RightClickMouseButton) are added to the context menu. How to remove selectively (I repeat that this thing doesn't work in all the docks, only one)? For example:
Special note_1
Special note_2
Special note_3
I want to remove only "Special note_1" how to implement in a macro?
:=::=::=::=::=::=::=::=::=::=::=::=::=::=::=::
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It looks like you want to assign your macro called "Special_note" to your newly added control. If so, try...

Code:
MyPoint.OnAction = "PERSONAL.XLSB!Special_note"

To delete it, try...

Code:
Application.CommandBars("Cell").Controls("Special note").Delete

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,532
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top