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?
:=::=::=::=::=::=::=::=::=::=::=::=::=::=::=::
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,003
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!
 

Forum statistics

Threads
1,081,563
Messages
5,359,617
Members
400,540
Latest member
JimUSMC

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top